Skip to content

Commit

Permalink
fix: Include captured exception on "Invalid JSON" errors (#1454)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirosen authored Sep 11, 2024
1 parent 397eb83 commit 87b2bf1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,8 +1277,8 @@ def json(self):
return None
try:
return json_loads(b)
except (ValueError, TypeError):
raise HTTPError(400, 'Invalid JSON')
except (ValueError, TypeError) as err:
raise HTTPError(400, 'Invalid JSON', exception=err)
return None

def _iter_body(self, read, bufsize):
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Release 0.14 (in development)
.. rubric:: Removed APIs (deprecated since 0.13)

* Removed the ``RouteReset`` exception and associated logic.
* ``bottle.HTTPError``\s raised on Invalid JSON now include the underlying exception
in their ``exception`` field.

Release 0.13
==============
Expand Down

0 comments on commit 87b2bf1

Please sign in to comment.