Feature error handler

I have moved all the work I did for setting an error handler onto a separate branch. This pull request includes all the commits. It replaces #19.

It extends the original pull request by allowing the error handler to be called from all functions, not just the non-multi functions. It is further called for connection errors as well.