error_1_13.go 516 B

1234567891011121314151617181920212223242526
  1. // +build go1.13
  2. package errors
  3. import (
  4. baseErrors "errors"
  5. )
  6. // Is detects whether the error is equal to a given error. Errors
  7. // are considered equal by this function if they are matched by errors.Is
  8. // or if their contained errors are matched through errors.Is
  9. func Is(e error, original error) bool {
  10. if baseErrors.Is(e, original) {
  11. return true
  12. }
  13. if e, ok := e.(*Error); ok {
  14. return Is(e.Err, original)
  15. }
  16. if original, ok := original.(*Error); ok {
  17. return Is(e, original.Err)
  18. }
  19. return false
  20. }