Skip to content
Myr

better override for json BadRequest error

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

authored by David Lord · committed by David Lord · parent 0a300d0 · Browse files · 1 file+7 added−5 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+7 added−5 removed

  • other:+7 added−5 removed

1 file+7 added−5 removed

modified:src/flask/wrappers.py+7 added-5 removed
7 unmodified lines
8from .globals import current_app9from .helpers import _split_blueprint_path1011if t.TYPE_CHECKING:12 import typing_extensions as te12 from werkzeug.routing import Rule131415class Request(RequestBase):
106 unmodified lines
122 from .debughelpers import attach_enctype_error_multidict123124 attach_enctype_error_multidict(self)125127 def on_json_loading_failed(self, e: Exception) -> "te.NoReturn":128 if current_app and current_app.debug:129 raise BadRequest(f"Failed to decode JSON object: {e}")126 def on_json_loading_failed(self, e: ValueError) -> t.Any:127 try:128 return super().on_json_loading_failed(e)129 except BadRequest as e:130 if current_app and current_app.debug:131 raise132131 raise BadRequest()133 raise BadRequest() from e134135136class Response(ResponseBase):137 """The response object that is used by default in Flask. Works like the
32 unmodified lines