You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I am currently writing some tests for our application, and I have specifically hit the issue that pkcs12.DecodeChain can return an error that is not easy to check for, due wrapping other errors with errors.New():
If the returned error here (and other locations where a dynamic error message can be returned) uses fmt.Errorf to wrap the error, I would be able to use errors.Is to check it, using code such as:
Right now I have to do some annoying string prefix equality check, which is brittle and prone to error..
What I suggest is to convert errors.New("pkcs12: error reading P12 data: " + err.Error()) to fmt.Errorf("pkcs12: error reading P12 data: %w", err.Error()).
This conversion should be done anywhere else, like:
Hello. I am currently writing some tests for our application, and I have specifically hit the issue that
pkcs12.DecodeChain
can return an error that is not easy to check for, due wrapping other errors witherrors.New()
:go-pkcs12/pkcs12.go
Line 526 in b59d8eb
If the returned error here (and other locations where a dynamic error message can be returned) uses
fmt.Errorf
to wrap the error, I would be able to useerrors.Is
to check it, using code such as:Right now I have to do some annoying string prefix equality check, which is brittle and prone to error..
What I suggest is to convert
errors.New("pkcs12: error reading P12 data: " + err.Error())
tofmt.Errorf("pkcs12: error reading P12 data: %w", err.Error())
.This conversion should be done anywhere else, like:
go-pkcs12/safebags.go
Line 31 in b59d8eb
go-pkcs12/safebags.go
Line 36 in b59d8eb
go-pkcs12/safebags.go
Line 31 in b59d8eb
go-pkcs12/safebags.go
Line 45 in b59d8eb
etc.
The text was updated successfully, but these errors were encountered: