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 categorization 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 interpolated into the msgFmt string, 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.