errors

package
v0.0.0-...-1ea1845 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 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 Error

type Error struct {
	Type    ErrorType
	Message string
	Cause   error
	Context map[string]any
}

func AsAppError

func AsAppError(err error) *Error

func BadRequestError

func BadRequestError(msg string) *Error

func ConflictError

func ConflictError(msg string) *Error

func ForbiddenError

func ForbiddenError(msg string) *Error

func GoneError

func GoneError(msg string, context map[string]any) *Error

GoneError reports a resource that existed but has ended; context details tell the client why.

func InternalError

func InternalError(msg string, cause error) *Error

func NotFoundError

func NotFoundError(msg string) *Error

func UnavailableError

func UnavailableError(msg string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) HTTPStatus

func (e *Error) HTTPStatus() int

func (*Error) ToResponse

func (e *Error) ToResponse() ErrorResponse

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorResponse

type ErrorResponse struct {
	Error   string         `json:"error"`
	Details map[string]any `json:"details,omitempty"`
}

type ErrorType

type ErrorType string
const (
	BadRequest  ErrorType = "bad_request"
	NotFound    ErrorType = "not_found"
	Conflict    ErrorType = "conflict"
	Forbidden   ErrorType = "forbidden"
	Gone        ErrorType = "gone"
	Unavailable ErrorType = "unavailable"
	Internal    ErrorType = "internal"
)

Jump to

Keyboard shortcuts

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