Documentation
¶
Overview ¶
Package errors provides error types with HTTP status codes for API error handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Code ¶ added in v0.7.0
Code extracts the HTTP status code from an error. It unwraps the error chain looking for a CodedError. If no CodedError is found, it returns http.StatusInternalServerError (500).
Types ¶
type CodedError ¶ added in v0.7.0
type CodedError struct {
// contains filtered or unexported fields
}
CodedError wraps an error with an HTTP status code. This allows errors to carry their intended HTTP response code through the call stack, enabling centralized error handling in API handlers.
func (*CodedError) Error ¶ added in v0.7.0
func (e *CodedError) Error() string
Error implements the error interface.
func (*CodedError) HTTPCode ¶ added in v0.7.0
func (e *CodedError) HTTPCode() int
HTTPCode returns the HTTP status code associated with this error.
func (*CodedError) Unwrap ¶ added in v0.7.0
func (e *CodedError) Unwrap() error
Unwrap returns the underlying error for errors.Is() and errors.As() compatibility.
Click to show internal directories.
Click to hide internal directories.