Skip to content
Myr

Merge pull request #3883 from tonydelanuez/clarify-got-request-exception

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Doc update: Clarify got_request_exception signal docs

authored by David Lord · committed by GitHub · parents 6355f12, 451c1f8 · Browse files · 1 file+22 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−8 removed

  • other:+22 added−8 removed

1 file+22 added−8 removed

modified:docs/api.rst+22 added-8 removed
438 unmodified lines
439 request_finished.connect(log_response, app)440441.. data:: got_request_exception442443 This signal is sent when an exception happens during request processing.444 It is sent *before* the standard exception handling kicks in and even445 in debug mode, where no exception handling happens. The exception446 itself is passed to the subscriber as `exception`.443 This signal is sent when an unhandled exception happens during444 request processing, including when debugging. The exception is445 passed to the subscriber as ``exception``.446448 Example subscriber::447 This signal is not sent for448 :exc:`~werkzeug.exceptions.HTTPException`, or other exceptions that449 have error handlers registered, unless the exception was raised from450 an error handler.451450 def log_exception(sender, exception, **extra):451 sender.logger.debug('Got exception during processing: %s', exception)452 This example shows how to do some extra logging if a theoretical453 ``SecurityException`` was raised:454455 .. code-block:: python456457 from flask import got_request_exception454 got_request_exception.connect(log_exception, app)458459 def log_security_exception(sender, exception, **extra):460 if not isinstance(exception, SecurityException):461 return462463 security_logger.exception(464 f"SecurityException at {request.url!r}",465 exc_info=exception,466 )467468 got_request_exception.connect(log_security_exception, app)469470.. data:: request_tearing_down471472 This signal is sent when the request is tearing down. This is always473 called, even if an exception is caused. Currently functions listening
301 unmodified lines