From a266db3ea0f03a0d919def491aafb4f638098fe5 Mon Sep 17 00:00:00 2001 From: Eric Seifert Date: Tue, 15 Jun 2021 15:43:35 -0700 Subject: [PATCH] Fix unhandled nil err check to prevent rpc causing a crash --- transl_utils/transl_utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transl_utils/transl_utils.go b/transl_utils/transl_utils.go index 8b3009d1b..7ac626b05 100644 --- a/transl_utils/transl_utils.go +++ b/transl_utils/transl_utils.go @@ -23,8 +23,11 @@ func __log_audit_msg(ctx context.Context, reqType string, uriPath string, err er var err1 error username := "invalid" statusMsg := "failure" + errMsg := "None" if (err == nil) { statusMsg = "success" + } else { + errMsg = err.Error() } if Writer == nil { @@ -38,7 +41,7 @@ func __log_audit_msg(ctx context.Context, reqType string, uriPath string, err er common_utils.GetUsername(ctx, &username) auditMsg := fmt.Sprintf("User \"%s\" request \"%s %s\" status - %s error - %s", - username, reqType, uriPath, statusMsg, err.Error()) + username, reqType, uriPath, statusMsg, errMsg) Writer.Info(auditMsg) }