MCPcopy Create free account
hub / github.com/cockroachdb/errors / EnsureNotInDomain

Function EnsureNotInDomain

domains/domains.go:124–138  ·  view source on GitHub ↗

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 err

(
	err error, constructor func(originalDomain Domain, err error) error, forbiddenDomains ...Domain,
)

Source from the content-addressed store, hash-verified

122// provided domain as new domain. The original error message
123// is preserved.
124func EnsureNotInDomain(
125 err error, constructor func(originalDomain Domain, err error) error, forbiddenDomains ...Domain,
126) error {
127 if err == nil {
128 return nil
129 }
130
131 // Is the error already in the wanted domains?
132 errDomain := GetDomain(err)
133 if notInDomainInternal(errDomain, forbiddenDomains...) {
134 // No: no-op.
135 return err
136 }
137 return constructor(errDomain, err)
138}
139
140// PackageDomain returns an error domain that represents the
141// package of its caller.

Callers 1

EnsureNotInDomainFunction · 0.92

Calls 2

notInDomainInternalFunction · 0.85
GetDomainFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…