1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

feat(api): replace all calls to http.Error with custom Error writer

This commit is contained in:
Anthony Lapenna 2017-01-24 16:35:48 +13:00
parent 1a868be6ea
commit d03e992b4f
4 changed files with 10 additions and 11 deletions

View file

@ -55,7 +55,9 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Error writes an API error message to the response and logger.
func Error(w http.ResponseWriter, err error, code int, logger *log.Logger) {
// Log error.
logger.Printf("http error: %s (code=%d)", err, code)
if logger != nil {
logger.Printf("http error: %s (code=%d)", err, code)
}
// Write generic error response.
w.WriteHeader(code)