Skip to content

Commit

Permalink
Adjusting the error checking example (#270)
Browse files Browse the repository at this point in the history
This PR adjusts the error checking example so that a check for an invalid signature is also included.

See discussion in #143
  • Loading branch information
oxisto authored Mar 24, 2023
1 parent b357385 commit 1c4047f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1c4047f

Please sign in to comment.