better override for json BadRequest error
This commit is contained in:
parent
0a300d007d
commit
6578b493c8
1 changed files with 7 additions and 5 deletions
|
|
@ -9,7 +9,6 @@ from .globals import current_app
|
||||||
from .helpers import _split_blueprint_path
|
from .helpers import _split_blueprint_path
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
import typing_extensions as te
|
|
||||||
from werkzeug.routing import Rule
|
from werkzeug.routing import Rule
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -124,11 +123,14 @@ class Request(RequestBase):
|
||||||
|
|
||||||
attach_enctype_error_multidict(self)
|
attach_enctype_error_multidict(self)
|
||||||
|
|
||||||
def on_json_loading_failed(self, e: Exception) -> "te.NoReturn":
|
def on_json_loading_failed(self, e: ValueError) -> t.Any:
|
||||||
if current_app and current_app.debug:
|
try:
|
||||||
raise BadRequest(f"Failed to decode JSON object: {e}")
|
return super().on_json_loading_failed(e)
|
||||||
|
except BadRequest as e:
|
||||||
|
if current_app and current_app.debug:
|
||||||
|
raise
|
||||||
|
|
||||||
raise BadRequest()
|
raise BadRequest() from e
|
||||||
|
|
||||||
|
|
||||||
class Response(ResponseBase):
|
class Response(ResponseBase):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue