Skip to content

Commit

Permalink
(fix) improve error messages in GetJWT
Browse files Browse the repository at this point in the history
  • Loading branch information
tphoney committed Dec 16, 2024
1 parent 31ab7b0 commit a0af443
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,16 @@ func (n *natsTokenClient) GetJWT() (string, error) {
// If we don't yet have a JWT, generate one
if n.jwt == "" {
err := n.generateJWT(ctx)

if err != nil {
err = fmt.Errorf("error generating JWT: %w", err)
span.SetStatus(codes.Error, err.Error())
return "", err
}
}

claims, err := jwt.DecodeUserClaims(n.jwt)

if err != nil {
err = fmt.Errorf("error decoding JWT: %w", err)
span.SetStatus(codes.Error, err.Error())
return n.jwt, err
}
Expand All @@ -258,8 +258,8 @@ func (n *natsTokenClient) GetJWT() (string, error) {
if vr.IsBlocking(true) {
// Regenerate the token
err := n.generateJWT(ctx)

if err != nil {
err = fmt.Errorf("error validating JWT: %w", err)
span.SetStatus(codes.Error, err.Error())
return "", err
}
Expand Down

0 comments on commit a0af443

Please sign in to comment.