More Elegant Exception Handling Than Multiple Catch Blocks? [duplicate]

In my opinion, a bunch of “ugly” catch blocks IS the best way to handle that situation.

The reason I prefer this is that it is very explicit. You are explicitly stating which exceptions you want to handle, and how they should be handled. Other forms of trying to merge handling into more concise forms lose readability in most cases.

My advice would be to stick to this, and handle the exceptions you wish to handle explicitly, each in their own catch block.

Leave a Comment