stac-fastapi icon indicating copy to clipboard operation
stac-fastapi copied to clipboard

Fix logging in exception handlers

Open geospatial-jeff opened this issue 2 years ago • 0 comments

The exc_info=True parameter in the exception handlers doesn't actually do anything because the log statement isn't within a except block. It should either be removed or updated to explicitly pass in exception traceback so it is logged:


exc = Exception
logger.error(
    "My error message",
    exc_info=(type(exc), exc, exc.__traceback__)
)

Logging every exception that triggers a handler might be overkill, we may just want to log traceback on 5XX responses?

https://github.com/stac-utils/stac-fastapi/blob/master/stac_fastapi/api/stac_fastapi/api/errors.py#L45

geospatial-jeff avatar Feb 27 '22 18:02 geospatial-jeff