Skip to content

Commit 7283815

Browse files
committed
404 for missing location data
1 parent 626ab8f commit 7283815

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/router/locations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fastapi import Request
1+
from fastapi import Request, HTTPException
22
from . import router
33
from ..enums.sources import Sources
44
from ..models.location import LocationResponse as Location, LocationsResponse as Locations
@@ -38,6 +38,8 @@ def get_locations(
3838
locations = [location for location in locations if str(getattr(location, key)).lower() == str(value)]
3939
except AttributeError:
4040
pass
41+
if not locations:
42+
raise HTTPException(404, detail=f"Source `{source}` does not have the desired location data.")
4143

4244
# Return final serialized data.
4345
return {

0 commit comments

Comments
 (0)