// New returns an error that formats as the given text.
New returns an error that formats as the given text.
// New returns an error that formats as the given text .
func New(status string, body io.Reader) error {
	var httpError HTTPError
	bodyBytes, err := ioutil.ReadAll(body)
	if err != nil {
		return fmt.Errorf("%v - %v", err.Error(), "Could not parse error message")
	}
	bodyString := string(bodyBytes)
	err = json.Unmarshal(bodyBytes, &httpError)
	if err != nil {
		return fmt.Errorf("%v - %v", err.Error(), bodyString)
	}
	httpError.Body = bodyString
	httpError.Status = status
	return &httpError
}
func New ( status string , body io . Reader ) error { var httpError HTTPError bodyBytes , err := ioutil . ReadAll ( body ) if err != nil { return fmt . Errorf ( " " , err . Error ( ) , " " ) } bodyString := string ( bodyBytes ) err = json . Unmarshal ( bodyBytes , & httpError ) if err != nil { return fmt . Errorf ( " " , err . Error ( ) , bodyString ) } httpError . Body = bodyString httpError . Status = status return & httpError }
New returns an error that formats as the given text.
New returns an error that formats as the given text .
// Attempt to parse the body