Skip to content

Commit

Permalink
fix(server): handle DownloadError and RequestError in server mode (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato authored Sep 1, 2023
1 parent 2af2d90 commit 3e9ec56
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions eodag/rest/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@
from eodag.utils import parse_header, update_nested_dict
from eodag.utils.exceptions import (
AuthenticationError,
DownloadError,
MisconfiguredError,
NoMatchingProductType,
NotAvailableError,
RequestError,
UnsupportedProductType,
UnsupportedProvider,
ValidationError,
Expand Down Expand Up @@ -249,6 +251,20 @@ async def handle_auth_error(request: Request, error):
)


@app.exception_handler(DownloadError)
@app.exception_handler(RequestError)
async def handle_server_error(request: Request, error):
"""These errors should be sent as internal server error with details to the client"""
logger.error(f"{type(error).__name__}: {str(error)}")
return await default_exception_handler(
request,
HTTPException(
status_code=500,
detail=f"{type(error).__name__}: {str(error)}",
),
)


@router.get("/", tags=["Capabilities"])
def catalogs_root(request: Request):
"""STAC catalogs root"""
Expand Down

0 comments on commit 3e9ec56

Please sign in to comment.