File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 11"""
22app.main.py
33"""
4- import os
5- import logging
64import datetime as dt
5+ import logging
6+ import os
77from typing import Dict , List
88
99import fastapi
@@ -93,6 +93,18 @@ async def add_datasource(request: fastapi.Request, call_next):
9393 return response
9494
9595
96+ # ################
97+ # Exception Handler
98+ # ################
99+
100+
101+ @APP .exception_handler (pydantic .error_wrappers .ValidationError )
102+ async def handle_validation_error (
103+ request : fastapi .Request , exc : pydantic .error_wrappers .ValidationError
104+ ):
105+ return fastapi .responses .JSONResponse ({"message" : exc .errors ()}, status_code = 422 )
106+
107+
96108# ################
97109# Routes
98110# ################
@@ -112,7 +124,7 @@ def get_latest(request: fastapi.Request):
112124
113125
114126@APP .get ("/locations" , response_model = AllLocations )
115- def get_all_locations (country_code : str = None , timelines : int = None ):
127+ def get_all_locations (country_code : str = None , timelines : int = 0 ):
116128 return
117129
118130
You can’t perform that action at this time.
0 commit comments