Skip to content

Commit d4e6e16

Browse files
fix; unwrap method to return concrete *Error type
1 parent ed85620 commit d4e6e16

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

inspection.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ func Cause(err error) error {
2929
return errors.Cause(err)
3030
}
3131

32-
// Unwrap returns the first occurrence of the underlying serializable Error type
33-
// using causer or create a new *Error type
34-
func Unwrap(err error) error {
32+
// Unwrap returns the first occurrence of the underlying *Error type
33+
// using causer or create a new *Error type containing the original error's message
34+
func Unwrap(err error) *Error {
35+
if err == nil {
36+
return nil
37+
}
3538
for err != nil {
36-
_, ok := err.(kinder)
39+
e, ok := err.(*Error)
3740
if ok {
38-
return err
41+
return e
3942
}
4043
cause, ok := err.(causer)
4144
if !ok {

0 commit comments

Comments
 (0)