errors

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides standardized domain errors that express business intent rather than infrastructure details. These errors should be used by use cases and mapped to appropriate HTTP status codes by handlers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates the requested resource does not exist.
	ErrNotFound = errors.New("not found")

	// ErrConflict indicates a conflict with existing data (e.g., duplicate key).
	ErrConflict = errors.New("conflict")

	// ErrInvalidInput indicates the input data is invalid or fails validation.
	ErrInvalidInput = errors.New("invalid input")

	// ErrUnauthorized indicates the request lacks valid authentication credentials.
	ErrUnauthorized = errors.New("unauthorized")

	// ErrForbidden indicates the authenticated user doesn't have permission.
	ErrForbidden = errors.New("forbidden")
)

Standard domain errors that can be used across all domain modules.

Functions

func As

func As(err error, target any) bool

As finds the first error in err's tree that matches target. This is a convenience wrapper around errors.As.

func Is

func Is(err, target error) bool

Is reports whether any error in err's tree matches target. This is a convenience wrapper around errors.Is.

func New

func New(message string) error

New creates a new error with the given message. This is a convenience wrapper around errors.New for consistency.

func Wrap

func Wrap(err error, message string) error

Wrap wraps an error with additional context while preserving the error chain. Use this to add context at each layer without losing the original error type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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