domains

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 16

Documentation

Index

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

func Handled(err error) error

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

func HandledInDomain(err error, domain Domain) error

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

func HandledInDomainWithMessage(err error, domain Domain, msg string) error

HandledInDomainWithMessage is like HandledWithMessage but with a domain.

func New

func New(msg string) error

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

func NotInDomain(err error, domains ...Domain) bool

NotInDomain returns true if and only if the error's domain is not one of the specified domains.

func WithDomain

func WithDomain(err error, domain Domain) error

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

func GetDomain(err error) Domain

GetDomain extracts the domain of the given error, or NoDomain if the error's cause does not have a domain annotation.

func NamedDomain

func NamedDomain(domainName string) Domain

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

func PackageDomainAtDepth(depth int) Domain

PackageDomainAtDepth returns an error domain that describes the package at the given call depth.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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