You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Wrap adds additional context to all error types while maintaining the type of the original error.
//
// This method behaves differently for each error type. For root errors, the stack trace is reset to the current
// callers which ensures traces are correct when using global/sentinel error values. Wrapped error types are simply
// wrapped with the new context. For external types (i.e. something other than root or wrap errors), this method
// attempts to unwrap them while building a new error chain. If an external type does not implement the unwrap
// interface, it flattens the error and creates a new root error from it before wrapping with the additional
// context.
it says for external types, it attempts to unwrap the (the unwrap interface), but I didn't find the Unwrap() is called
btw, what is the best practice to wrap an external error, say
type MyError struct {
Code int // error code
}
The text was updated successfully, but these errors were encountered:
according to the document of Wrap(),
// Wrap adds additional context to all error types while maintaining the type of the original error.
//
// This method behaves differently for each error type. For root errors, the stack trace is reset to the current
// callers which ensures traces are correct when using global/sentinel error values. Wrapped error types are simply
// wrapped with the new context. For external types (i.e. something other than root or wrap errors), this method
// attempts to unwrap them while building a new error chain. If an external type does not implement the unwrap
// interface, it flattens the error and creates a new root error from it before wrapping with the additional
// context.
it says for external types, it attempts to unwrap the (the unwrap interface), but I didn't find the Unwrap() is called
btw, what is the best practice to wrap an external error, say
type MyError struct {
Code int // error code
}
The text was updated successfully, but these errors were encountered: