Exemplo n.º 1
0
// 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)
}