jwt
jwt copied to clipboard
Please add err.types
Migrated from https://github.com/dgrijalva/jwt-go/issues/375:
Filet-de-S commented on Jan 18, 2020 •
It's inconvenient to check it with strcmp instead of switch err.(type)
*jwt.ValidationError is the same for "invalid signature" as for any other like from custom Valid() method. It would be great if we could set it manually. Thanks.
A further improvement aside from splitting ValidationError into derived types would be making them 1.13 compliant (that is, compatible with the Is/As and Unwrap errors package methods). That would make the refactor worth it and allow for error type assertions in a more idiomatic way than type swtiching
A further improvement aside from splitting ValidationError into derived types would be making them 1.13 compliant (that is, compatible with the Is/As and Unwrap errors package methods). That would make the refactor worth it and allow for error type assertions in a more idiomatic way than type swtiching
I agree, I would also like to go the 1.13 error types route.
I have trouble with this too. It seems like the fix is simple: add an Unwrap
method in errors.go:
func (e ValidationError) Unwrap() error {
return e.Inner
}
Fixed by #234