joomcode / errorx

A comprehensive error handling library for Go
MIT License
1.13k stars 29 forks source link

Add helper methods for the "errors" package #28

Closed pacejackson closed 3 years ago

pacejackson commented 4 years ago

~This just calls 'Error.Cause()' but allows the Errors to interop with the 'errors' package from the Go standard library. The main benefit is you can use 'errors.Is' to see if an Error was due to some standard error like context.Canceled.~

~Add an Is method to *Error. This is the helper method for errors.Is so you can use that to check your errors. It uses Error.IsOfType if it can (when target is an *Error), otherwise it falls back to iterating through the error chain until it reaches a non-*Error error and calls errors.Is against that error.~

Add all of the helper methods for the "errors" package behind a build flag so they are only available for Go 1.13+.

PeterIvanov commented 4 years ago

@pacejackson please tell if you're going to update this PR based on what's discussed above.

PeterIvanov commented 3 years ago

@pacejackson no activity here since last I wrote. Presently I'm going to revisit this subject and either submit changes based on this pull request, or create a new one.

PeterIvanov commented 3 years ago

Closing this pull request in favor of https://github.com/joomcode/errorx/pull/32