Skip to content

Commit 43a2f1f

Browse files
chore: add exception handling to nisar_orbit_ephemera endpoint
1 parent 52529ee commit 43a2f1f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/SearchAPI/application/application.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,16 @@ async def kml_to_footprint(granule: str, cmr_token: Optional[str] = None, maturi
260260
@router.get('/services/utils/nisar_orbit_ephemera')
261261
async def get_nisar_orbit_ephemera():
262262
"""Returns the latest nisar orbit ephemera products for POE, MOE, NOE, and FOE in that order. Returns as jsonlite2"""
263-
oe_dict = asf.utils.get_nisar_orbit_ephemeras()
264-
results = ASFSearchResults([product for product in oe_dict.values()])
265-
response_info = as_output(results, 'jsonlite2')
266-
return Response(**response_info)
263+
try:
264+
oe_dict = asf.utils.get_nisar_orbit_ephemeras()
265+
results = ASFSearchResults([product for product in oe_dict.values()])
266+
response_info = as_output(results, 'jsonlite2')
267+
return Response(**response_info)
268+
except (asf.ASFSearchError, asf.CMRError, ValueError) as exc:
269+
raise HTTPException(
270+
detail=f"Search failed to find results: {exc}",
271+
status_code=400
272+
) from exc
267273

268274
# example: https://api.daac.asf.alaska.edu/services/redirect/NISAR_L2_STATIC/{granule_id}.h5
269275
# @router.get('/services/redirect/{short_name}/{granule_id}')

0 commit comments

Comments
 (0)