-
-
Notifications
You must be signed in to change notification settings - Fork 774
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
Added support for special handling in RethrowCaughtException #907
Added support for special handling in RethrowCaughtException #907
Conversation
It does not report caught exception that are rethrown if there is work done before that. reference #906
Please add test cases for just logging a message and not using the exception. |
fun x() { | ||
try { | ||
} catch (e: IllegalStateException) { | ||
print("log") |
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.
According to sonar this should get reported, should't it? (https://sbforge.org/sonar/rules/show/squid:S1166?modal=true&layout=false)
// Noncompliant - exception is lost (only message is preserved)
try { /* ... */ } catch (Exception e) { LOGGER.info(e.getMessage()); }
The exception name must be used in any statement to not lose the exception?
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.
So should we make the rule stricter? @arturbosch
So this gets reported
try {
} catch (e: Exception) {
log()
log(e.message)
throw e
}
and this does not
try {
} catch (e: Exception) {
log(e) // e is used here
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.
I would say yes, lets how I interpret sonarqube's doc.
The rule checks if the rethrown caught exception is used before.
reference #906