mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-12 13:36:41 +00:00
🔊 Log body parsing errors
This commit is contained in:
parent
b763a44328
commit
9a6fcdd13c
3 changed files with 6 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
||||||
|
|
||||||
__version__ = "0.1.4"
|
__version__ = "0.1.5"
|
||||||
|
|
||||||
from .applications import FastAPI
|
from .applications import FastAPI
|
||||||
from .routing import APIRouter
|
from .routing import APIRouter
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,10 @@ try:
|
||||||
from pydantic.types import EmailStr # type: ignore
|
from pydantic.types import EmailStr # type: ignore
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"email-validator not installed, email fields will be treated as str.\n" +
|
"email-validator not installed, email fields will be treated as str.\n"
|
||||||
"To install, run: pip install email-validator"
|
+ "To install, run: pip install email-validator"
|
||||||
)
|
)
|
||||||
|
|
||||||
class EmailStr(str): # type: ignore
|
class EmailStr(str): # type: ignore
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ def get_app(
|
||||||
body[field] = value
|
body[field] = value
|
||||||
else:
|
else:
|
||||||
body = await request.json()
|
body = await request.json()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logging.error("Error getting request body", e)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400, detail="There was an error parsing the body"
|
status_code=400, detail="There was an error parsing the body"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue