Skip to content

Commit e84f1b1

Browse files
committed
remove build tag from extention methods
1 parent 1a3d895 commit e84f1b1

2 files changed

Lines changed: 19 additions & 22 deletions

File tree

error.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ func (e *Error) Cause() error {
156156
return e.cause
157157
}
158158

159+
// Is returns true if and only if target is errorx error that passes errorx type check against current error.
160+
// This behaviour is exactly the same as that of IsOfType().
161+
// See also: errors.Is()
162+
func (e *Error) Is(target error) bool {
163+
typedTarget := Cast(target)
164+
return typedTarget != nil && IsOfType(e, typedTarget.Type())
165+
}
166+
167+
// From errors package: if e.Unwrap() returns a non-nil error w, then we say that e wraps w.
168+
// Unwrap returns cause of current error in case it is wrapped transparently, nil otherwise.
169+
// See also: errors.Unwrap()
170+
func (e *Error) Unwrap() error {
171+
if e.cause != nil && e.transparent {
172+
return e.cause
173+
} else {
174+
return nil
175+
}
176+
}
177+
159178
// Format implements the Formatter interface.
160179
// Supported verbs:
161180
//

error_113.go

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)