Issue 96 improved exception handling

I initially applied just the patch that is described in #96, but then wanted to go further -- primarily so that on the python side I can distinguish between exception types and decide whether to locally handle the exception or whether to propagate the exception up (perhaps with exception rewrapping).