errors

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

func ToHTTP

func ToHTTP(err error, w http.ResponseWriter)

ToHTTP writes a structured JSON error response. Handlers call this in their error paths — no error-handling middleware needed.

Types

type Code

type Code int

Code is an enum of domain error codes. Maps to HTTP status codes for the server, and to exit codes / user messages for the CLI.

const (
	CodeUnknown Code = iota
	CodeNotFound
	CodeConflict
	CodeBadRequest
	CodeUnauthorized
	CodeForbidden
	CodeInternal
)

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is the single error type for all domain errors. Handlers use ToHTTP() to convert it; CLI commands inspect Code() for UX.

func Conflict

func Conflict(resource, slug string) *Error

func New

func New(code Code, message string) *Error

func NotFound

func NotFound(resource, slug string) *Error

func (*Error) Code

func (e *Error) Code() Code

func (*Error) Error

func (e *Error) Error() string

func (*Error) HTTPStatus

func (e *Error) HTTPStatus() int

func (*Error) Hint

func (e *Error) Hint() string

func (*Error) WithHint

func (e *Error) WithHint(hint string) *Error

type RefError

type RefError struct {
	Err         *Error
	InvalidRefs map[string]any
}

RefError carries structured invalid-reference details alongside a validation error. Used by RefChecker and surfaced in API responses.

func (*RefError) Error

func (e *RefError) Error() string

func (*RefError) Unwrap

func (e *RefError) Unwrap() error

Jump to

Keyboard shortcuts

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