From 43a8284c076e8792818e7832595e389874b24fcb Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Wed, 14 May 2014 18:02:18 -0700 Subject: [PATCH] Relax exception check so that it only warns on catching Throwable and Error. Fix #159 --- analysis/pokemon.d | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/analysis/pokemon.d b/analysis/pokemon.d index 82cb42d..5ee0257 100644 --- a/analysis/pokemon.d +++ b/analysis/pokemon.d @@ -15,7 +15,7 @@ import analysis.base; * --- * try { * choose(pikachu); - * } catch (Exception e) { + * } catch (Throwable e) { * ... * } * --- @@ -42,13 +42,12 @@ class PokemonExceptionCheck : BaseAnalyzer c.accept(this); return; } - if (identOrTemplate.identifier.text == "Exception" - || identOrTemplate.identifier.text == "Throwable" + if (identOrTemplate.identifier.text == "Throwable" || identOrTemplate.identifier.text == "Error") { immutable column = identOrTemplate.identifier.column; 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); }