-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Lines 97 to 107 in 8d2f336
try: | |
return FileResponse( | |
path=f'{config.paths["processed_pdfs"]}/{namespace}/{pdf_file_name}', | |
media_type="application/pdf", | |
filename=pdf_file_name, | |
) | |
except FileNotFoundError: | |
raise HTTPException(status_code=404, detail="No processed file found") | |
except Exception: | |
logger.error("Error", exc_info=1) | |
raise HTTPException(status_code=422) |
These exceptions are not reachable, due to the fact that the exception from FileResponse is raised after the return.
As noted in https://stackoverflow.com/questions/74103330/fastapi-fileresponse-not-entering-the-except-block/74103398#74103398 a simple os.stat()
on the file's path before the return is enough to trigger the exceptions as expected.
Metadata
Metadata
Assignees
Labels
No labels