statuserr

package
v0.0.3-beta.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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 BadRequestError(err error, messages ...string) HTTPError

func ForbiddenError

func ForbiddenError(err error, messages ...string) HTTPError

func InternalServerError

func InternalServerError(err error, messages ...string) HTTPError

func NewBadRequestError

func NewBadRequestError(message string) HTTPError

func NewError

func NewError(status, code int32, message string, err error) HTTPError

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 NewForbiddenError(message string) HTTPError

func NewInternalServerError

func NewInternalServerError(message string) HTTPError

func NewNotFoundError

func NewNotFoundError(message string) HTTPError

func NewUnauthorizedError

func NewUnauthorizedError(message string) HTTPError

func NewWithStatus

func NewWithStatus(status int32, message string) HTTPError

func NotFoundError

func NotFoundError(err error, messages ...string) HTTPError

func UnauthorizedError

func UnauthorizedError(err error, messages ...string) HTTPError

func WithStatus

func WithStatus(status int32, err error, messages ...string) HTTPError

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL