🔊 Log body parsing errors

This commit is contained in:
Sebastián Ramírez 2018-12-10 17:54:53 +04:00
parent b763a44328
commit 9a6fcdd13c
3 changed files with 6 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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"
) )