1 //go:build go1.13 2 // +build go1.13 3 4 package errors 5 6 import ( 7 baseErrors "errors" 8 ) 9 10 // As finds the first error in err's tree that matches target, and if one is found, sets 11 // target to that error value and returns true. Otherwise, it returns false. 12 // 13 // For more information see stdlib errors.As. 14 func As(err error, target interface{}) bool { 15 return baseErrors.As(err, target) 16 } 17 18 // Is detects whether the error is equal to a given error. Errors 19 // are considered equal by this function if they are matched by errors.Is 20 // or if their contained errors are matched through errors.Is. 21 func Is(e error, original error) bool { 22 if baseErrors.Is(e, original) { 23 return true 24 } 25 26 if e, ok := e.(*Error); ok { 27 return Is(e.Err, original) 28 } 29 30 if original, ok := original.(*Error); ok { 31 return Is(e, original.Err) 32 } 33 34 return false 35 } 36