Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Fix unhandled nil err check to prevent rpc causing a crash (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
seiferteric authored Jul 28, 2021
1 parent 6df988c commit 085f29d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion transl_utils/transl_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down

0 comments on commit 085f29d

Please sign in to comment.