Error
builtin errors
Built-in error variables
var (
ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType)
ErrNotFound = NewHTTPError(http.StatusNotFound)
ErrUnauthorized = NewHTTPError(http.StatusUnauthorized)
ErrForbidden = NewHTTPError(http.StatusForbidden)
ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed)
ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge)
ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests)
ErrBadRequest = NewHTTPError(http.StatusBadRequest)
ErrBadGateway = NewHTTPError(http.StatusBadGateway)
ErrInternalServerError = NewHTTPError(http.StatusInternalServerError)
ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout)
ErrServiceUnavailable = NewHTTPError(http.StatusServiceUnavailable)
ErrValidatorNotRegistered = errors.New("slim: validator not registered")
ErrRendererNotRegistered = errors.New("slim: renderer not registered")
ErrInvalidRedirectCode = errors.New("slim: invalid redirect status code")
ErrCookieNotFound = errors.New("slim: cookie not found")
ErrInvalidCertOrKeyType = errors.New("slim: invalid cert or key type, must be string or []byte")
ErrInvalidListenerNetwork = errors.New("slim: invalid listener network")
ErrFilesystemNotRegistered = errors.New("slim: filesystem not registered")
)
func NewHTTPError
func NewHTTPError(code int, message ...any) *HTTPError
Creates an HTTP error instance.
func NewHTTPErrorWithInternal
func NewHTTPErrorWithInternal(code int, internalError error, message ...any) *HTTPError
Creates an HTTP error instance with an internal error.
type HTTPError
// HTTPError represents an error that occurred while handling a request.
type HTTPError struct {
Code int `json:"-"`
Message any `json:"message"`
Internal error `json:"-"` // Stores the error returned by an external dependency
}
HTTP error struct that represents an error that occurred while handling a request.
func (*HTTPError) Error
func (he *HTTPError) Error() string
Implements the error interface.
func (*HTTPError) WithInternal
func (he *HTTPError) WithInternal(err error) *HTTPError
Copies the current instance and sets the internal error.
func (*HTTPError) Unwrap
func (he *HTTPError) Unwrap() error
Implements the error wrapper interface.