diff --git a/wrap.go b/wrap.go index eb929db..5d1097e 100644 --- a/wrap.go +++ b/wrap.go @@ -19,6 +19,9 @@ var ( // Without args, leaves the provided message intact, so a message may be generated or provided externally. // With args, a formatting is performed, and it is therefore expected a format string to be constant. func Decorate(err error, message string, args ...interface{}) *Error { + if err == nil { + return nil + } return NewErrorBuilder(transparentWrapper). WithConditionallyFormattedMessage(message, args...). WithCause(err). @@ -30,6 +33,9 @@ func Decorate(err error, message string, args ...interface{}) *Error { // Designed to be used when a original error is passed from another goroutine rather than from a direct method call. // If, however, it is called in the same goroutine, formatter makes some moderated effort to remove duplication. func EnhanceStackTrace(err error, message string, args ...interface{}) *Error { + if err == nil { + return nil + } return NewErrorBuilder(transparentWrapper). WithConditionallyFormattedMessage(message, args...). WithCause(err).