emperror.dev/errors@v0.8.1/wrap_go1_13.go (about) 1 // +build go1.13 2 3 package errors 4 5 import ( 6 "errors" 7 ) 8 9 // Is reports whether any error in err's chain matches target. 10 // 11 // An error is considered to match a target if it is equal to that target or if 12 // it implements a method Is(error) bool such that Is(target) returns true. 13 func Is(err, target error) bool { 14 return errors.Is(err, target) 15 } 16 17 // As finds the first error in err's chain that matches the type to which target 18 // points, and if so, sets the target to its value and returns true. An error 19 // matches a type if it is assignable to the target type, or if it has a method 20 // As(interface{}) bool such that As(target) returns true. As will panic if target 21 // is not a non-nil pointer to a type which implements error or is of interface type. 22 // 23 // The As method should set the target to its value and return true if err 24 // matches the type to which target points. 25 func As(err error, target interface{}) bool { 26 return errors.As(err, target) 27 }