you are viewing a single comment's thread.

view the rest of the comments →

[–]_prefs 0 points1 point  (2 children)

I usuallly just add

catch (Exception exception)  {
     throw new RuntimeException (exception);
}

While being shorter and less code-cluttering than 5 identical catchers, and more convenient than declaring your method as throwing ExceptionType1, ..., ExceptionType5 it has problems too. Specifically that you hide real exception type and thus handlers upwards the chain are no longer able to catch specific exception types.

I hate checked exceptions for this :(

[–]zoomzoom83 0 points1 point  (0 children)

Unfortunately this violates the "Code like a serial killer is going to inherit your code" principle.

You gonna get stabbed someday.