Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Join ¶ added in v0.4.0
Join combines several errors into one that carries the call site, for the case where an operation fans out and more than one branch can fail independently — several sinks written to, several items in a batch. nil errors are ignored, and Join returns nil when every error is nil.
The result unwraps to what the standard library's errors.Join produces, so errors.Is and errors.As still find any of the joined errors.
func MapError ¶ added in v0.3.0
func MapError(from, to error)
MapError registers a single translation from -> to. Useful for incremental registration across packages in init(). No-op if either err is nil.
func SetErrorMap ¶ added in v0.3.0
SetErrorMap replaces the global translation map. Intended to be called once at startup. Entries with a nil key or nil value are skipped.
Types ¶
type CTXError ¶ added in v0.2.0
type CTXError struct {
// contains filtered or unexported fields
}
CTXError holds the wrapped error and additional context.
func (*CTXError) As ¶ added in v0.8.0
As finds the first error in the error map's translation of the wrapped error that matches target. errors.As falls back to the original chain through Unwrap when this reports false.
func (*CTXError) Error ¶ added in v0.2.0
Error returns the formatted error message, including file and function details. When the error map translated the wrapped error, the message shows the translation, not the original error.
func (*CTXError) Is ¶ added in v0.8.0
Is reports whether the error map's translation of the wrapped error matches target. errors.Is calls it before following Unwrap, so a wrapped error matches both its translation and everything in its original chain.
func (*CTXError) Mapped ¶ added in v0.9.0
Mapped returns the error map's translation of the wrapped error, or nil when no entry matched.
func (*CTXError) Original ¶ added in v0.9.0
Original returns the error passed to Wrap or Wrapf, before any error map translation, or nil when e wraps nothing. Its message is never part of Error() once a translation applied, so reach for it only when the raw cause is really needed, for example in internal diagnostics.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package commerr provides common, general-purpose sentinel errors — not-found, already-exists, invalid-argument, timeout, unavailable, and the like — so any Go code can return and match a shared one with errors.Is instead of re-declaring the same errors in every package.
|
Package commerr provides common, general-purpose sentinel errors — not-found, already-exists, invalid-argument, timeout, unavailable, and the like — so any Go code can return and match a shared one with errors.Is instead of re-declaring the same errors in every package. |
