Documentation
¶
Index ¶
- type CodeError
- type HTTPError
- func BadRequestError(err error, messages ...string) HTTPError
- func ForbiddenError(err error, messages ...string) HTTPError
- func InternalServerError(err error, messages ...string) HTTPError
- func NewBadRequestError(message string) HTTPError
- func NewError(status, code int32, message string, err error) HTTPError
- func NewForbiddenError(message string) HTTPError
- func NewInternalServerError(message string) HTTPError
- func NewNotFoundError(message string) HTTPError
- func NewUnauthorizedError(message string) HTTPError
- func NewWithStatus(status int32, message string) HTTPError
- func NotFoundError(err error, messages ...string) HTTPError
- func UnauthorizedError(err error, messages ...string) HTTPError
- func WithStatus(status int32, err error, messages ...string) HTTPError
- type MessageError
- type StatusError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeError ¶
type CodeError interface {
error
// GetCode returns the custom error code associated with this error.
GetCode() int32
}
CodeError represents an error that carries a custom error code. This is useful for application-specific error classification beyond HTTP status.
type HTTPError ¶
type HTTPError interface {
error
StatusError
CodeError
MessageError
}
HTTPError is a comprehensive error type that includes HTTP status, custom code, and user message.
func BadRequestError ¶
func ForbiddenError ¶
func InternalServerError ¶
func NewBadRequestError ¶
func NewError ¶
NewError creates a new error with HTTP status, custom code, and user message. It returns the broader HTTPError interface to avoid exposing the concrete type and keep the API surface stable. If err is nil, a default HTTP error based on the status is used.
func NewForbiddenError ¶
func NewInternalServerError ¶
func NewNotFoundError ¶
func NewUnauthorizedError ¶
func NewWithStatus ¶
func NotFoundError ¶
func UnauthorizedError ¶
type MessageError ¶
type MessageError interface {
error
// GetMessage returns the user-friendly message associated with this error.
GetMessage() string
}
MessageError represents an error that carries a user-friendly message. This allows separation between technical error details and user-facing messages.
type StatusError ¶
type StatusError interface {
error
// GetStatus returns the HTTP status code associated with this error.
GetStatus() int32
}
StatusError represents an error that carries an HTTP status code. This interface allows errors to be categorized by their HTTP semantics.