File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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//
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments