]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✨ Preserve `json.JSONDecodeError` information when handling invalid JSON in request...
authorSidharth Ajithkumar <sidharthajithkumar@gmail.com>
Thu, 25 Aug 2022 09:55:53 +0000 (15:25 +0530)
committerGitHub <noreply@github.com>
Thu, 25 Aug 2022 09:55:53 +0000 (11:55 +0200)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
fastapi/routing.py

index 80bd53279a31fe75898d9607fc2726dd04839e9d..8f4d0fa7ef578e97b1dfc7e68bdfb662edcab981 100644 (file)
@@ -209,7 +209,9 @@ def get_request_handler(
                         else:
                             body = body_bytes
         except json.JSONDecodeError as e:
-            raise RequestValidationError([ErrorWrapper(e, ("body", e.pos))], body=e.doc)
+            raise RequestValidationError(
+                [ErrorWrapper(e, ("body", e.pos))], body=e.doc
+            ) from e
         except Exception as e:
             raise HTTPException(
                 status_code=400, detail="There was an error parsing the body"