func encodeResponseErr(w http.ResponseWriter, err interface{}) {
	enc := json.NewEncoder(w)

	rErr, ok := err.(*apitypes.Error)
	if ok {
		w.WriteHeader(rErr.StatusCode)
		enc.Encode(rErr)
	} else {
		w.WriteHeader(http.StatusInternalServerError)
		enc.Encode(&errorMsg{
			Type:  apitypes.InternalServerError,
			Error: []string{"Internal server error"},
		})
	}
}
// if encoding has errored, our struct is either bad, or our writer
// is broken. Try writing an error back to the client, but ignore any
// problems (ie the writer is broken).
if encoding has errored, our struct is either bad, or our writer
is broken. Try writing an error back to the client, but ignore any
problems .
// if encoding has errored our struct is either bad or our writer // is broken . Try writing an error back to the client but ignore any // problems ( ie the writer is broken ) .
func encodeResponseErr(w http.ResponseWriter, err interface{}) {
	enc := json.NewEncoder(w)
	rErr, ok := err.(*apitypes.Error)
	if ok {
		w.WriteHeader(rErr.StatusCode)
		enc.Encode(rErr)
	} else {
		w.WriteHeader(http.StatusInternalServerError)
		enc.Encode(&errorMsg{
			Type:  apitypes.InternalServerError,
			Error: []string{"Internal server error"},
		})
	}
}
func encodeResponseErr ( w http . ResponseWriter , err interface { } ) { enc := json . NewEncoder ( w ) rErr , ok := err . ( * apitypes . Error ) if ok { w . WriteHeader ( rErr . StatusCode ) enc . Encode ( rErr ) } else { w . WriteHeader ( http . StatusInternalServerError ) enc . Encode ( & errorMsg { Type : apitypes . InternalServerError , Error : [ ] string { " " } , } ) } }
if encoding has errored, our struct is either bad, or our writer
is broken.
if encoding has errored our struct is either bad or our writer is broken .