jwt icon indicating copy to clipboard operation
jwt copied to clipboard

Please add err.types

Open lggomez opened this issue 3 years ago • 3 comments

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.

lggomez avatar Aug 03 '21 12:08 lggomez

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

lggomez avatar Aug 03 '21 12:08 lggomez

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.

oxisto avatar Aug 03 '21 13:08 oxisto

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
}

chowey avatar Oct 16 '21 15:10 chowey

Fixed by #234

oxisto avatar Feb 21 '23 18:02 oxisto