Update to Java 7: Multi-catch exception handling

The newest upcoming release of Brigade will require Java 7 on the client side, and Java 8 on the server side.  I have spent considerable time lately combing through the code base and optimizing to use the new features in these updated Java versions.

One of my favorites has been the exception “multi-catch” feature added in Java 7.  This allows multiple exception types to be caught and handled using pretty much identical code.  When exceptions of multiple types are possible, pre-Java 7 you would be forced to write “catch” blocks of code to handle each type independently.  Typically, however, there is a lot of similarity in how these exceptions are handled.  After all, whatever you were trying to do failed, and that is the bottom line.  Most common handling involves logging the exception, and maybe displaying a message to the user to indicate that something went wrong.  In switching over to the new multi-catch features, this can be done succinctly in just a couple of lines.

In online game development, there is a lot that can go wrong, typically involving I/O, network, and socket exceptions, let alone game state & database exceptions.  Handling each of these individually was painful and resulted in a lot of needless code bloat, so it is definitely nice to streamline things using this new feature.

If you want to see more detail about the new multi-catch feature, there are some more complete descriptions here and here.