Add 401 and 403 default errors

This commit is contained in:
Dan Jones 2024-02-07 08:57:14 -06:00
commit 0e12c479be
2 changed files with 29 additions and 5 deletions

10
new.go
View file

@ -20,6 +20,16 @@ func NewBadRequest(format string, parts ...any) SettableError {
return Errorf(http.StatusBadRequest, format, parts...)
}
// A 401 error with the error message "Unauthorized"
func NewUnauthorized() SettableError {
return Errorf(http.StatusUnauthorized, "Unauthorized")
}
// A 403 error with the error message "Forbidden"
func NewForbidden() SettableError {
return Errorf(http.StatusForbidden, "Forbidden")
}
// Represents a 500 error. For this error, the user error is preset to "Unknown Error".
func NewInternalError(format string, parts ...any) SettableError {
status := http.StatusInternalServerError