🔊 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"""
__version__ = "0.1.4"
__version__ = "0.1.5"
from .applications import FastAPI
from .routing import APIRouter

View File

@ -10,9 +10,10 @@ try:
from pydantic.types import EmailStr # type: ignore
except ImportError:
logging.warning(
"email-validator not installed, email fields will be treated as str.\n" +
"To install, run: pip install email-validator"
"email-validator not installed, email fields will be treated as str.\n"
+ "To install, run: pip install email-validator"
)
class EmailStr(str): # type: ignore
pass

View File

@ -61,7 +61,8 @@ def get_app(
body[field] = value
else:
body = await request.json()
except Exception:
except Exception as e:
logging.error("Error getting request body", e)
raise HTTPException(
status_code=400, detail="There was an error parsing the body"
)