0

During my code scanning through sonarqube. I had found these warning. "Declaration Of Catch For Generic Exception"

**} catch (Exception e) { - RelevantPart: catch**

If any one face same please help me :

Sunil Kumar
  • 127
  • 2
  • 8
  • The warning means instead of catching the base class Exception, you should catch the specific type of exception you expect to be thrown. – khelwood Jul 23 '21 at 11:12
  • [Is it really that bad to catch a general exception?](https://stackoverflow.com/q/21938/3890632) – khelwood Jul 23 '21 at 11:13
  • You mean to say i need to use try{} catch (IOException e) { logger.error("doExchange failed", e); } – Sunil Kumar Jul 23 '21 at 11:15
  • If IOException is the exception you actually need to deal with, yes, that is what the warning is about. Whether you do what it says or not is up to you. – khelwood Jul 23 '21 at 11:17

0 Answers0