If I understand the comment right, the solution is to first use pattern-inside to mark that you're interested in all try-except blocks, and then pattern-not-inside to remove the ones that correctly reraise the exception. Could you check this out? https://semgrep.dev/s/underyx:always-reraise
If this helped, I recommend joining https://r2c.dev/slack — we've got a #rules channel dedicated to solving problems like this :)
As I understood it, the GP is looking to flag the non-usage of the "ke" variable in the exception body.
Why did the approach mentioned not work?
1) recognize all exception bodies.
2) recognize all exception bodies that use the ke variable and mark them as okay.
Anything left should be an exception body that didn't use the ke variable, right ?
I'll show the Java version first, because it's more obvious, then the equivalent in Python to stay moderately on-topic
In the python version, I would accept the presence of `logger.exception` but my question in both code snippets is how to detect that nothing touches the exception variable within the catch block