add the ability to use a custom error handler

We need the ability to handle exceptions (and not lose any exceptions.) This allows for an optional error handler.