'This method is called whenever an exception occurs that should be
handled.  A special case are
:class:`~werkzeug.exception.HTTPException`\s which are forwarded by
this function to the :meth:`handle_http_exception` method.  This
function will either return a response value or reraise the
exception with the same traceback.
.. versionchanged:: 1.0
Key errors raised from request data like ``form`` show the the bad
key in debug mode rather than a generic bad request message.
.. versionadded:: 0.7'

def handle_user_exception(self, e):

    (exc_type, exc_value, tb) = sys.exc_info()
    assert (exc_value is e)
    if ((self.debug or self.config['TRAP_BAD_REQUEST_ERRORS']) and isinstance(e, BadRequestKeyError) and (e.description is BadRequestKeyError.description)):
        e.description = "KeyError:    '{0}'".format(*e.args)
    if (isinstance(e, HTTPException) and (not self.trap_http_exception(e))):
        return self.handle_http_exception(e)
    handler = self._find_error_handler(e)
    if (handler is None):
        reraise(exc_type, exc_value, tb)
    return handler(e)
