Support for custom error handlers in API library