cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Introduce support for wrapped errors in the codebase

Open 3vilhamster opened this issue 9 months ago • 1 comments

What changed? I've switched all direct error handling to usage of either errors.Is or errors.As. I've split the PR into commits so it can be reviewed commit by commit. Most of the changes are converting expressions to an identical one so no logical changes are expected:

if _, ok := err.(*customErr); ok {

to

if errors.As(err, new(*customErr)) {

There were a couple of more complicated cases, but all could be resolved.

Why? This is a mandatory step to improve existing error handling that does not provide a clear path of where the error is coming from. In all style guides, error wrapping is recommended, but the codebase should be ready to handle wrapped errors instead of exact type checks.

How did you test it? Unit/integration tests.

Potential risks Potentially, some errors could be misclassified.

Release notes

Documentation Changes

3vilhamster avatar May 22 '24 11:05 3vilhamster