Skip to content

Commit

Permalink
fix unwrap on typed nil (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
isopov authored Jul 4, 2023
1 parent 9f7c73f commit a1c187a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (e *Error) Is(target error) bool {
// Unwrap returns cause of current error in case it is wrapped transparently, nil otherwise.
// See also: errors.Unwrap()
func (e *Error) Unwrap() error {
if e.cause != nil && e.transparent {
if e != nil && e.cause != nil && e.transparent {
return e.cause
} else {
return nil
Expand All @@ -170,9 +170,9 @@ func (e *Error) Unwrap() error {
// Format implements the Formatter interface.
// Supported verbs:
//
// %s simple message output
// %v same as %s
// %+v full output complete with a stack trace
// %s simple message output
// %v same as %s
// %+v full output complete with a stack trace
//
// In is nearly always preferable to use %+v format.
// If a stack trace is not required, it should be omitted at the moment of creation rather in formatting.
Expand Down

0 comments on commit a1c187a

Please sign in to comment.