Skip to content
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

SwallowedException false negative #2049

Closed
jamiehunt opened this issue Oct 23, 2019 · 0 comments · Fixed by #2436
Closed

SwallowedException false negative #2049

jamiehunt opened this issue Oct 23, 2019 · 0 comments · Fixed by #2436

Comments

@jamiehunt
Copy link

Expected Behavior

The following code block should be considered non-compliant:

try {
} catch (e: IllegalStateException) {
    var message = e.message  // e is swallowed
    throw IllegalArgumentException(message)
} catch (f: Exception) {
    var message = f.toString()  // f is swallowed
    throw Exception(IllegalArgumentException(message))
}

Observed Behavior

Code passes the SwalowedException check

Steps to Reproduce

Use the sample code provided, or similar where exception message is stored and passed into new exception.

Context

Trying to prevent instances of swallowed exceptions

Your Environment

  • Version of detekt used: 1.1.x
  • Version of Gradle used (if applicable): N/A
  • Operating System and version: N/A
  • Link to your project (if it's a public repository): N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants