I am trying to find all instances of the following
catch (Exception e) {
String errMsg = "Something went wrong: " + e;
// log message
}
since multiple issues with debugging have happened because the exception was mistakenly concatenated with the error message, instead of being supplied as a throwable for the logger or as a cause for a new exception. I know that Intellij’s structural search has a template for “String concatenations with many operands”:
$a$ + $b$
// whole template modifier: Type=java.lang.String
but it seems unclear as to what it is actually capturing. Is it just capturing any string concatenation? The name implies that it would actually capture concatenations like "a" + "b" + "c" + "d"
Regardless, can a similar format be used to find any time an exception is concatenated to a string inside of a catch block? Along the lines of
catch($ExceptionType$ $Exception$) {
String errMsg = $a$ + $Exception$;
// possibly also detect logging
}
This question is continuing my attempt to solve the issue described here