Error Handlers Builder

class eynnyd.error_handlers_builder.ErrorHandlersBuilder[source]

An object for setting handlers for any exceptions that can come up.

There are two times an error can be thrown in the process of turning a request into a response. Either the error occurs before we have a response or after. Handlers should be set based on where the exception is expected (or in both places if it can come up anywhere).

Handling will prefer the most specific exception but will execute against a base exception if one was set.

Several default handlers are set if they are not set manually. The defaults registered are for RouteNotFound, InvalidCookieHeader, and Exception.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

add_pre_response_error_handler(error_class, handler)[source]

Add error handlers which happen before we have built a response (returned from a handler).

Parameters
  • error_class – The class to execute the handler for.

  • handler – A function which takes a request as a parameter.

Returns

This builder so that fluent design can optionally be used.

add_post_response_error_handler(error_class, handler)[source]

Add error handlers which happen after we have built a response.

Parameters
  • error_class – The class to execute the handler for.

  • handler – A function which takes both a request and response parameter.

Returns

This builder so that fluent design can optionally be used.

build()[source]

set defaults and build the error handlers for setting into the Eynnyd WebAppBuilder.

return

The ErrorHandlers required by the Eynnyd WebAppBuilder set_error_handlers method.