error_backward.go 470 B

12345678910111213141516171819202122
  1. // +build !go1.13
  2. package errors
  3. // Is detects whether the error is equal to a given error. Errors
  4. // are considered equal by this function if they are the same object,
  5. // or if they both contain the same error inside an errors.Error.
  6. func Is(e error, original error) bool {
  7. if e == original {
  8. return true
  9. }
  10. if e, ok := e.(*Error); ok {
  11. return Is(e.Err, original)
  12. }
  13. if original, ok := original.(*Error); ok {
  14. return Is(e, original.Err)
  15. }
  16. return false
  17. }