2024-01-17 15:52:08 -06:00
|
|
|
package errors
|
|
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
|
|
// Represents a 404 error.
|
|
|
|
|
func NewNotFound(format string, parts ...any) SettableError {
|
|
|
|
|
if format == "" {
|
|
|
|
|
format = "Not Found"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Errorf(http.StatusNotFound, format, parts...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Represents a 400 error.
|
|
|
|
|
func NewBadRequest(format string, parts ...any) SettableError {
|
|
|
|
|
if format == "" {
|
|
|
|
|
format = "Bad Request"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Errorf(http.StatusBadRequest, format, parts...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
msg := "Unknown Error"
|
2024-01-19 22:37:13 -06:00
|
|
|
return Errorf(status, format, parts...).SetMsg(msg)
|
2024-01-17 15:52:08 -06:00
|
|
|
}
|