apperr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeInternal         = "internal"
	CodeNotFound         = "not_found"
	CodeBadRequest       = "bad_request"
	CodeValidation       = "validation"
	CodeUnauthorized     = "unauthorized"
	CodeForbidden        = "forbidden"
	CodePayloadTooLarge  = "payload_too_large"
	CodeRateLimited      = "rate_limited"
	CodeTimeout          = "timeout"
	CodeMethodNotAllowed = "method_not_allowed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    string
	Status  int
	Message string
	Cause   error
}

Error represents a structured application error.

func As

func As(err error) *Error

As extracts an *Error if present.

func BadRequest

func BadRequest(message string, cause error) *Error

BadRequest creates a bad request error.

func Forbidden

func Forbidden(message string, cause error) *Error

Forbidden creates a forbidden error.

func Internal

func Internal(message string, cause error) *Error

Internal creates an internal error.

func MethodNotAllowed

func MethodNotAllowed(message string, cause error) *Error

MethodNotAllowed creates a method not allowed error.

func New

func New(code string, status int, message string, cause error) *Error

New creates a new Error.

func NotFound

func NotFound(message string, cause error) *Error

NotFound creates a not found error.

func PayloadTooLarge

func PayloadTooLarge(message string, cause error) *Error

PayloadTooLarge creates a payload too large error.

func RateLimited

func RateLimited(message string, cause error) *Error

RateLimited creates a rate limited error.

func Timeout

func Timeout(message string, cause error) *Error

Timeout creates a timeout error.

func Unauthorized

func Unauthorized(message string, cause error) *Error

Unauthorized creates an unauthorized error.

func Validation

func Validation(message string, cause error) *Error

Validation creates a validation error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the root cause.

Jump to

Keyboard shortcuts

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