Perform a deep check, unwrapping errors as much as possilbe and comparing the string version of the error.
(err, errConst error)
| 252 | // Perform a deep check, unwrapping errors as much as possilbe and |
| 253 | // comparing the string version of the error. |
| 254 | func IsError(err, errConst error) bool { |
| 255 | if err == errConst { |
| 256 | return true |
| 257 | } |
| 258 | // Must rely on string equivalence, otherwise a value is not equal |
| 259 | // to its pointer value. |
| 260 | rootErrStr := "" |
| 261 | rootErr := RootError(err) |
| 262 | if rootErr != nil { |
| 263 | rootErrStr = rootErr.Error() |
| 264 | } |
| 265 | errConstStr := "" |
| 266 | if errConst != nil { |
| 267 | errConstStr = errConst.Error() |
| 268 | } |
| 269 | return rootErrStr == errConstStr |
| 270 | } |
| 271 | |
| 272 | // Performs a deep check of wrapped errors to find one which is selected by the given |
| 273 | // classifier func. The classifer is called on all non-nil errors found, starting with topErr, |