Relax exception check so that it only warns on catching Throwable and Error. Fix #159
This commit is contained in:
parent
8b4b2b342f
commit
43a8284c07
|
@ -15,7 +15,7 @@ import analysis.base;
|
||||||
* ---
|
* ---
|
||||||
* try {
|
* try {
|
||||||
* choose(pikachu);
|
* choose(pikachu);
|
||||||
* } catch (Exception e) {
|
* } catch (Throwable e) {
|
||||||
* ...
|
* ...
|
||||||
* }
|
* }
|
||||||
* ---
|
* ---
|
||||||
|
@ -42,13 +42,12 @@ class PokemonExceptionCheck : BaseAnalyzer
|
||||||
c.accept(this);
|
c.accept(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (identOrTemplate.identifier.text == "Exception"
|
if (identOrTemplate.identifier.text == "Throwable"
|
||||||
|| identOrTemplate.identifier.text == "Throwable"
|
|
||||||
|| identOrTemplate.identifier.text == "Error")
|
|| identOrTemplate.identifier.text == "Error")
|
||||||
{
|
{
|
||||||
immutable column = identOrTemplate.identifier.column;
|
immutable column = identOrTemplate.identifier.column;
|
||||||
immutable line = identOrTemplate.identifier.line;
|
immutable line = identOrTemplate.identifier.line;
|
||||||
addErrorMessage(line, column, "Avoid catching Exception, Error, and Throwable");
|
addErrorMessage(line, column, "Catching Error or Throwable is a really bad idea.");
|
||||||
}
|
}
|
||||||
c.accept(this);
|
c.accept(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue