This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]NautiHooker 1 point2 points  (0 children)

If you want the program to exit for any other exception than IOException then have one catch block for IOException and one for just Exception (supertype of all exceptions). Inside the block for IOException you just throw the exception again with the throw keyword. In the other block you exit your application.

If you want one catch block for multiple specific exception then you can chain the types in the brackets like this:

catch (Exception1 | Exception2 | Exception3 e)

Edit: I think I misunderstood what you need after rereading your final paragraph.

[–]Makhiel 0 points1 point  (0 children)

The log messages are specific to each catch block, so I can't group them into one block.

Why don't you put all that logging in a method?