errcodes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyRequestBody

func EmptyRequestBody() error

EmptyRequestBody reports a missing body on a request that requires one.

func MalformedPayload

func MalformedPayload() error

MalformedPayload reports a request body that could not be decoded.

func NotFound

func NotFound(resource string) error

NotFound reports that a resource does not exist.

func UnknownParameter

func UnknownParameter(param string) error

UnknownParameter reports a request parameter that is not part of the input type.

func UnsupportedMediaType

func UnsupportedMediaType() error

UnsupportedMediaType reports an unsupported request content type.

func ValidationError

func ValidationError(message string) error

ValidationError reports a request that failed validation.

func ValidationFields

func ValidationFields(message string, fields map[string]string) error

func ValidationTypeError

func ValidationTypeError(message string) error

ValidationTypeError reports a value that could not be converted to the expected type.

Types

type Error

type Error struct {
	HTTPCode int
	Message  string
	Code     string
}

Error is an API error with a stable machine-readable code.

func (*Error) Error

func (err *Error) Error() string

func (*Error) Is

func (err *Error) Is(target error) bool

type ErrorDetail

type ErrorDetail struct {
	Code       string            `json:"code"`
	Message    string            `json:"message"`
	StatusCode int               `json:"status_code"`
	Fields     map[string]string `json:"fields,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error ErrorDetail `json:"error"`
}

ErrorResponse is the browser API's shared error contract.

type FieldError

type FieldError struct {
	Cause  error
	Fields map[string]string
}

FieldError attaches field-specific messages while preserving the shared error code.

func (*FieldError) Error

func (e *FieldError) Error() string

func (*FieldError) Unwrap

func (e *FieldError) Unwrap() error

type Handler

type Handler struct{}

Handler converts application and Echo errors into the API error envelope.

func NewHandler

func NewHandler() *Handler

func (*Handler) Handle

func (h *Handler) Handle(c *echo.Context, err error)

Handle is an Echo HTTP error handler.

Jump to

Keyboard shortcuts

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