Throw a long list of exceptions vs throw an Exception vs throw custom exception?
- by athena
I have an application which uses two methods of an API. Both these methods throw more than five exceptions each. So, if I just add a throws declaration then it becomes a list of more than ten. (My method cannot handle any of the ten exceptions)
I have read that throwing a long list of exceptions is a bad practice. Also throwing (the umbrella) Exception is a bad practice. So, what should I do?
Add a try catch block, and log and exit in the catch block? (Current approach)
Create a custom exception class, wrap every exception and throw the custom exception?
Add a throws declaration for all exceptions?
Throw Exception?