Exception handling

I've made some improvements to the exception handling of the library:

1. Unexpected situations should not write an error to stdout, instead, throw a custom exception or fail using ```error``` when it's really not supposed to happen. This allows users of the library to deal with such situations, instead of just seeing some message in their logs.

2. Exceptions should not be caught and just written to stdout, for the same reasons as above.

3. The handler that runs when a connection is closed could not distinguish between closings due to user request or an exception. I've made a simple change that records any exception and provides this to the handler so users of the library can distinguish the two cases. Note that this does change the interface of ```addConnectionClosedHandler```. If desired, a wrapper function can be added to preserve the old interface. But, in general one wants to know why a connection was closed, so changing the interface is justifiable to me.