-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update exception handling in PFX.verifyAuthSafes() #1002
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is invoked by the CLI so if there is an error the user get the stacktrace. I think the original approach with a reason message was better. Could we just add the exception message to the reason to make clearer what is the problem? Is it possible to add more information when the CLI run in debug mode?
reason.append("An exception occurred converting the password from chars to bytes"); | ||
return false; | ||
} catch (Exception e) { | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are not doing any action with the exception then try/catch could be totally removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, the try-catch is removed now.
Previously the PFX.verifyAuthSafes() discarded the original exception and simply returned a generic error message which was usually insufficient to determine the cause of the issue. To help troubleshooting, the PFX.verifyAuthSafes() has been modified to throw the exception so the original error message and the stack trace are preserved.
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@fmarco76 Please see the updated patch. I removed the try-catch statement as you suggested. As for the stack trace, I think it's better to let the application (i.e. CLI or UI) handle the exception. Currently by default the CLI will only show the exception message without the stack trace, for example:
However, for troubleshooting we can run the CLI in verbose mode to see the stack trace:
The original code removed the exception info completely so it's not possible to see the stack trace at all, and the original error messages were too generic to be useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@fmarco76 Thanks! |
Previously the
PFX.verifyAuthSafes()
discarded the original exception and simply returned a generic error message which was usually insufficient to determine the cause of the issue.To help troubleshooting, the
PFX.verifyAuthSafes()
has been modified to throw the exception so the original error message and the stack trace are preserved.