apperr

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = New("not_found") // Common error used when a resource could not be found.

Functions

func As

func As[T error](err error) (T, bool)

Same as errors.As but with generics =D

func New

func New(code string) error

Instantiates a new RuleError with the given code.

func NewWithDetail

func NewWithDetail(code string, detailErr error) error

Instantiates a new RuleError error which wrap the detail error.

func Wrap

func Wrap(err error, detail error) error

Wrap the given detail error into the base err. If err is an RuleError, its Detail field will be populated, else a new RuleError will be created.

Types

type Error

type Error struct {
	Code   string `json:"code"`
	Detail error  `json:"detail,omitempty"`
}

Represents an application error with an optional detail. Application errors represent an expected error from the domain perspective. Infrastructure errors should use the standard errors package.

func (Error) Error

func (e Error) Error() string

func (Error) Is

func (e Error) Is(err error) bool

func (Error) Unwrap

func (e Error) Unwrap() error

Jump to

Keyboard shortcuts

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