s3manager-web/errors.go
2017-04-09 16:28:57 +02:00

24 lines
499 B
Go

package main
import (
"log"
"net/http"
)
// Common error messages within the app
const (
ErrBucketDoesNotExist = "The specified bucket does not exist."
ErrKeyDoesNotExist = "The specified key does not exist."
)
// handleHTTPError handles HTTP errors
func handleHTTPError(w http.ResponseWriter, statusCode int, err error) {
msg := http.StatusText(statusCode)
http.Error(w, msg, statusCode)
logMsg := msg
if err != nil {
logMsg = logMsg + ": " + err.Error()
}
log.Println(logMsg)
}