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 f6e6592
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,7 +258,7 @@ func (n *natsTokenClient) GetJWT() (string, error) {
if vr.IsBlocking(true) {
// Regenerate the token
err := n.generateJWT(ctx)

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

0 comments on commit f6e6592

Please sign in to comment.