Skip to content

Commit a1c187a

Browse files
authored
fix unwrap on typed nil (#42)
1 parent 9f7c73f commit a1c187a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

error.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (e *Error) Is(target error) bool {
160160
// Unwrap returns cause of current error in case it is wrapped transparently, nil otherwise.
161161
// See also: errors.Unwrap()
162162
func (e *Error) Unwrap() error {
163-
if e.cause != nil && e.transparent {
163+
if e != nil && e.cause != nil && e.transparent {
164164
return e.cause
165165
} else {
166166
return nil
@@ -170,9 +170,9 @@ func (e *Error) Unwrap() error {
170170
// Format implements the Formatter interface.
171171
// Supported verbs:
172172
//
173-
// %s simple message output
174-
// %v same as %s
175-
// %+v full output complete with a stack trace
173+
// %s simple message output
174+
// %v same as %s
175+
// %+v full output complete with a stack trace
176176
//
177177
// In is nearly always preferable to use %+v format.
178178
// If a stack trace is not required, it should be omitted at the moment of creation rather in formatting.

0 commit comments

Comments
 (0)