Documentation ¶
Index ¶
- func EnsureNotInDomain(err error, constructor func(originalDomain Domain, err error) error, ...) error
- func Handled(err error) error
- func HandledInDomain(err error, domain Domain) error
- func HandledInDomainWithMessage(err error, domain Domain, msg string) error
- func New(msg string) error
- func NotInDomain(err error, domains ...Domain) bool
- func WithDomain(err error, domain Domain) error
- type Domain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureNotInDomain ¶
func EnsureNotInDomain( err error, constructor func(originalDomain Domain, err error) error, forbiddenDomains ...Domain, ) error
EnsureNotInDomain checks whether the error is in the given domain(s). If it is, the given constructor if provided is called to construct an alternate error. If no error constructor is provided, a new barrier is constructed automatically using the first provided domain as new domain. The original error message is preserved.
func Handled ¶
Handled creates a handled error in the implicit domain (see PackageDomain() below) of its caller.
See the documentation of `barriers.Handled()` for details.
func HandledInDomain ¶
HandledInDomain creates an error in the given domain and retains the details of the given original error as context for debugging. The original error is hidden and does not become a "cause" for the new error. The original's error _message_ is preserved.
See the documentation of `WithDomain()` and `errors.Handled()` for details.
func HandledInDomainWithMessage ¶
HandledInDomainWithMessage is like HandledWithMessage but with a domain.
func New ¶
New creates an error in the implicit domain (see PackageDomain() below) of its caller.
Domain is shown: - via `errors.GetSafeDetails()`. - when formatting with `%+v`. - in Sentry reports.
func NotInDomain ¶
NotInDomain returns true if and only if the error's domain is not one of the specified domains.
func WithDomain ¶
WithDomain wraps an error so that it appears to come from the given domain.
Domain is shown: - via `errors.GetSafeDetails()`. - when formatting with `%+v`. - in Sentry reports.
Types ¶
type Domain ¶
type Domain string
Domain is the type of a domain annotation.
const NoDomain Domain = "error domain: <none>"
NoDomain is the domain of errors that don't originate from a barrier.
func GetDomain ¶
GetDomain extracts the domain of the given error, or NoDomain if the error's cause does not have a domain annotation.
func NamedDomain ¶
NamedDomain returns an error domain identified by the given string.
func PackageDomain ¶
func PackageDomain() Domain
PackageDomain returns an error domain that represents the package of its caller.
func PackageDomainAtDepth ¶
PackageDomainAtDepth returns an error domain that describes the package at the given call depth.