errors

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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