コード例 #1
0
ファイル: request.go プロジェクト: brettbates/json-binding
// TODO Should rewrite to send a 'fail' or an 'error'
func ErrorHandler(rw web.ResponseWriter, err error) {
	if rw.Written() {
		panic(fmt.Sprintf("Data already started to be sent to the client and i had an error: %s", err))
	}
	rw.WriteHeader(http.StatusBadRequest)
	fmt.Fprintf(rw, "{\"Error\": \"%s\"}", err)
}