Created
November 26, 2013 20:57
-
-
Save boopathi/7666107 to your computer and use it in GitHub Desktop.
Error Adapter - Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func errorAdapter(f func(http.ResponseWriter, *http.Request) error) http.HandlerFunc { | |
return func(w http.ResponseWriter, r *http.Request) { | |
c := appengine.NewContext(r) | |
err := f(w, r) | |
if err != nil { | |
c.Errorf("Handler returned an error: %s", err) | |
http.Error(w, err.Error(), http.StatusInternalServerError) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment