Allow the caller to specify an error handler.