s3manager-web/errors.go

25 lines
521 B
Go
Raw Normal View History

2017-05-08 23:07:07 +02:00
package s3manager
2017-04-09 16:28:57 +02:00
import (
"log"
"net/http"
)
2017-05-08 23:07:07 +02:00
// Error codes that may be returned from an S3 backend.
2017-04-09 16:28:57 +02:00
const (
ErrBucketDoesNotExist = "The specified bucket does not exist."
ErrKeyDoesNotExist = "The specified key does not exist."
)
2017-05-08 23:07:07 +02:00
// handleHTTPError handles HTTP errors.
2017-04-09 16:28:57 +02:00
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)
}