errdefs

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errdefs provides behavior-based error classification.

Errors are classified by marker interfaces rather than error codes. Each category has three associated items:

  • An unexported marker interface (e.g. interface{ NotFound() })
  • A constructor that wraps/creates errors with the marker
  • A check function (e.g. IsNotFound)

Sentinel errors remain plain stdlib errors; classification is orthogonal to identity — errors.Is checks identity, IsXxx checks category.

Index

Constants

This section is empty.

Variables

View Source
var (
	Is     = errors.Is
	As     = errors.As
	Unwrap = errors.Unwrap
	Join   = errors.Join
)

Re-export standard library functions so callers only need one import.

Functions

func Aborted

func Aborted(err error) error

func Abortedf

func Abortedf(format string, args ...any) error

func Conflict

func Conflict(err error) error

func Conflictf

func Conflictf(format string, args ...any) error

func Fmt

func Fmt(format string, args ...any) error

Fmt creates a formatted error with optional wrapping (re-export of fmt.Errorf).

func Forbidden

func Forbidden(err error) error

func Forbiddenf

func Forbiddenf(format string, args ...any) error

func HTTPStatus

func HTTPStatus(err error) int

HTTPStatus returns the HTTP status code for an error based on its category. Unknown/uncategorized errors map to 500 Internal Server Error.

func Internal

func Internal(err error) error

func Internalf

func Internalf(format string, args ...any) error

func Interrupted

func Interrupted(err error) error

func Interruptedf

func Interruptedf(format string, args ...any) error

func IsAborted

func IsAborted(err error) bool

func IsConflict

func IsConflict(err error) bool

func IsForbidden

func IsForbidden(err error) bool

func IsInternal

func IsInternal(err error) bool

func IsInterrupted

func IsInterrupted(err error) bool

func IsNotAvailable

func IsNotAvailable(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsRateLimit

func IsRateLimit(err error) bool

func IsTimeout

func IsTimeout(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func IsValidation

func IsValidation(err error) bool

func New

func New(text string) error

New creates a plain error (re-export of stdlib errors.New).

func NotAvailable

func NotAvailable(err error) error

func NotAvailablef

func NotAvailablef(format string, args ...any) error

func NotFound

func NotFound(err error) error

func NotFoundf

func NotFoundf(format string, args ...any) error

func RateLimit

func RateLimit(err error) error

func RateLimitf

func RateLimitf(format string, args ...any) error

func Timeout

func Timeout(err error) error

func Timeoutf

func Timeoutf(format string, args ...any) error

func Unauthorized

func Unauthorized(err error) error

func Unauthorizedf

func Unauthorizedf(format string, args ...any) error

func Validation

func Validation(err error) error

func Validationf

func Validationf(format string, args ...any) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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