From 1c4047f488ec4e73d7b6ffafd7bff78ab82a1cc4 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Fri, 24 Mar 2023 23:11:38 +0100 Subject: [PATCH] Adjusting the error checking example (#270) This PR adjusts the error checking example so that a check for an invalid signature is also included. See discussion in #143 --- example_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/example_test.go b/example_test.go index 58fdea43..abf7efab 100644 --- a/example_test.go +++ b/example_test.go @@ -164,6 +164,9 @@ func ExampleParse_errorChecking() { fmt.Println("You look nice today") } else if errors.Is(err, jwt.ErrTokenMalformed) { fmt.Println("That's not even a token") + } else if errors.Is(err, jwt.ErrTokenSignatureInvalid) { + // Invalid signature + fmt.Println("Invalid signature") } else if errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet) { // Token is either expired or not active yet fmt.Println("Timing is everything")