mirror of https://github.com/pallets/flask.git
fix error message
This commit is contained in:
parent
7b0c82dfdc
commit
633449a36c
|
@ -15,6 +15,8 @@ Unreleased
|
||||||
- ``app.json_encoder`` and ``json_decoder`` are only passed to
|
- ``app.json_encoder`` and ``json_decoder`` are only passed to
|
||||||
``dumps`` and ``loads`` if they have custom behavior. This improves
|
``dumps`` and ``loads`` if they have custom behavior. This improves
|
||||||
performance, mainly on PyPy. :issue:`4349`
|
performance, mainly on PyPy. :issue:`4349`
|
||||||
|
- Fix error message for ``after_this_request`` when it used outside
|
||||||
|
request context. :issue:`4333`
|
||||||
|
|
||||||
|
|
||||||
Version 2.0.2
|
Version 2.0.2
|
||||||
|
|
|
@ -130,7 +130,15 @@ def after_this_request(f: AfterRequestCallable) -> AfterRequestCallable:
|
||||||
|
|
||||||
.. versionadded:: 0.9
|
.. versionadded:: 0.9
|
||||||
"""
|
"""
|
||||||
_request_ctx_stack.top._after_request_functions.append(f)
|
top = _request_ctx_stack.top
|
||||||
|
if top is None:
|
||||||
|
raise RuntimeError(
|
||||||
|
"This decorator can only be used at local scopes "
|
||||||
|
"when a request context is on the stack. For instance within "
|
||||||
|
"view functions."
|
||||||
|
)
|
||||||
|
top._after_request_functions.append(f)
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue