Try catch added on ingest

This commit is contained in:
Saurab-Shrestha 2024-02-27 10:38:44 +05:45
parent a8a10e412e
commit 484b6b7223
2 changed files with 34 additions and 26 deletions

View File

@ -294,6 +294,7 @@ async def common_ingest_logic(
)
# Handling Original File
if original_file:
try:
print("ORIGINAL PDF FILE PATH IS :: ", original_file)
file_name = Path(original_file).name
upload_path = Path(f"{UPLOAD_DIR}/{file_name}")
@ -322,6 +323,13 @@ async def common_ingest_logic(
with open(upload_path, "rb") as f:
ingested_documents = service.ingest_bin_data(file_name, f)
except Exception as e:
print(traceback.print_exc())
raise HTTPException(
status_code=500,
detail="Internal Server Error: Unable to ingest file.",
)
logger.info(
f"{file_name} is uploaded by the {current_user.fullname}.")