MicahParks/keyfunc

Wrapping error causes

msanft opened this issue · 3 comments

Hey there!

It seems that most errors created by this library seem not to wrap the errors that caused them. Is there any reasoning behind that? I think doing so would make debugging at a first glance a lot easier.

For example, consider this:

keyfunc/keyfunc.go

Lines 97 to 100 in d272c92

store, err := jwks.ToStorage()
if err != nil {
return nil, fmt.Errorf("%w: could not create JWK Set storage", ErrKeyfunc)
}

If the returned error would wrap the causing err, one could easily figure out why this failed, without constructing their own debugging setup or using a dynamic debugger.

Cheers, Moritz.

The reason is because error behavior was copied from /v2, which was based on an older version of Go.

Now that /v3 has access to errors.Join, which was added in Go 1.20, the package should be wrapping errors with this function.

I'll add this behavior and do a release this evening, eastern USA timezone.

Thank you for bringing this to my attention!

Please see the newest release v3.2.3 where each error should be wrapped where appropriate.

Thank you so much! Unbelievable that you've addressed this so fast! <3