From a0af4432d4b2631fa08ee517beb793c75605c996 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Mon, 16 Dec 2024 10:47:07 +0000 Subject: [PATCH] (fix) improve error messages in GetJWT --- auth/auth.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auth/auth.go b/auth/auth.go index 8f702f9..4c7ebf2 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -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 } @@ -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 }