Skip to main content

Wrapf

Wraps a root cause error with another. This is useful to unify an error type in a package.

def Wrapf(
code: ErrorCode,
cause: error,
msgFmt: string,
args: ...interface{}
) - > error

Wraps a root cause error with another. This is useful to unify an error type in a package.

Parameters

NameTypeDescription
codeErrorCodeThe specific error code to associate with the new error, providing a categorized identifier for the error.
causeerrorThe underlying root cause error that is being wrapped, allowing for error chaining and inspection of the original problem.
msgFmtstringThe format string for the new error message, similar to fmt.Sprintf, used to construct a descriptive message.
args...interface{}Arguments to be formatted into msgFmt, providing dynamic content for the error message.

Returns

TypeDescription
errorA new error that wraps the original cause error, including a specified error code and formatted message.