mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-09 01:47:03 +00:00
30 lines
667 B
Go
30 lines
667 B
Go
package errorhandler
|
|
|
|
import (
|
|
"errors"
|
|
log "github.com/sirupsen/logrus"
|
|
"net/http"
|
|
)
|
|
|
|
var (
|
|
InvalidSecurityLevelError = errors.New("InvalidSecurityLevel")
|
|
InvalidLocaleError = errors.New("InvalidLocale")
|
|
)
|
|
|
|
func respondError(w http.ResponseWriter, statusCode int, cause error) {
|
|
log.Error(cause)
|
|
w.WriteHeader(statusCode)
|
|
}
|
|
|
|
func InternalError(w http.ResponseWriter, cause error) {
|
|
respondError(w, http.StatusInternalServerError, cause)
|
|
}
|
|
|
|
func BadRequest(w http.ResponseWriter, cause error) {
|
|
respondError(w, http.StatusBadRequest, cause)
|
|
}
|
|
|
|
func Unauthorized(w http.ResponseWriter, cause error) {
|
|
respondError(w, http.StatusUnauthorized, cause)
|
|
}
|