File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed
Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ Unreleased
1414 If subclasses were overriding these methods, the old signature is detected,
1515 shows a deprecation warning, and will continue to work during the
1616 deprecation period. :issue: `5815 `
17+ - The ``should_ignore_error `` is deprecated. Handle errors as needed in
18+ teardown handlers instead. :issue: `5816 `
1719- ``template_filter ``, ``template_test ``, and ``template_global `` decorators
1820 can be used without parentheses. :issue: `5729 `
1921- ``redirect `` returns a ``303 `` status code by default instead of ``302 ``.
Original file line number Diff line number Diff line change @@ -995,6 +995,17 @@ def full_dispatch_request(self, ctx: AppContext) -> Response:
995995
996996 .. versionadded:: 0.7
997997 """
998+ if not self ._got_first_request and self .should_ignore_error is not None :
999+ import warnings
1000+
1001+ warnings .warn (
1002+ "The 'should_ignore_error' method is deprecated and will"
1003+ " be removed in Flask 3.3. Handle errors as needed in"
1004+ " teardown handlers instead." ,
1005+ DeprecationWarning ,
1006+ stacklevel = 1 ,
1007+ )
1008+
9981009 self ._got_first_request = True
9991010
10001011 try :
@@ -1576,7 +1587,11 @@ def wsgi_app(
15761587 if "werkzeug.debug.preserve_context" in environ :
15771588 environ ["werkzeug.debug.preserve_context" ](ctx )
15781589
1579- if error is not None and self .should_ignore_error (error ):
1590+ if (
1591+ error is not None
1592+ and self .should_ignore_error is not None
1593+ and self .should_ignore_error (error )
1594+ ):
15801595 error = None
15811596
15821597 ctx .pop (error )
Original file line number Diff line number Diff line change @@ -922,15 +922,16 @@ def trap_http_exception(self, e: Exception) -> bool:
922922
923923 return False
924924
925- def should_ignore_error (self , error : BaseException | None ) -> bool :
926- """This is called to figure out if an error should be ignored
927- or not as far as the teardown system is concerned. If this
928- function returns ``True`` then the teardown handlers will not be
929- passed the error.
925+ should_ignore_error : None = None
926+ """If this method returns ``True``, the error will not be passed to
927+ teardown handlers, and the context will not be preserved for
928+ debugging.
930929
931- .. versionadded:: 0.10
932- """
933- return False
930+ .. deprecated:: 3.2
931+ Handle errors as needed in teardown handlers instead.
932+
933+ .. versionadded:: 0.10
934+ """
934935
935936 def redirect (self , location : str , code : int = 303 ) -> BaseResponse :
936937 """Create a redirect response object.
You can’t perform that action at this time.
0 commit comments