mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +03:00
fix(backend): fix error messages (#2917)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
6359cff5cc
commit
4dfb3049c8
@ -62,19 +62,27 @@ async def upload_file(
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
notification_service.update_notification_by_id(
|
||||
notification_id,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.ERROR,
|
||||
description=f"There was an error uploading the file: {e}",
|
||||
),
|
||||
)
|
||||
if "The resource already exists" in str(e):
|
||||
notification_service.update_notification_by_id(
|
||||
notification_id,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.ERROR,
|
||||
description=f"File {upload_file.filename} already exists in storage.",
|
||||
),
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail=f"File {upload_file.filename} already exists in storage.",
|
||||
)
|
||||
|
||||
else:
|
||||
notification_service.update_notification_by_id(
|
||||
notification_id,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.ERROR,
|
||||
description=f"There was an error uploading the file",
|
||||
),
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=500, detail=f"Failed to upload file to storage. {e}"
|
||||
)
|
||||
|
@ -82,19 +82,27 @@ async def upload_file(
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
notification_service.update_notification_by_id(
|
||||
upload_notification.id if upload_notification else None,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.ERROR,
|
||||
description=f"There was an error uploading the file: {e}",
|
||||
),
|
||||
)
|
||||
|
||||
if "The resource already exists" in str(e):
|
||||
notification_service.update_notification_by_id(
|
||||
upload_notification.id if upload_notification else None,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.ERROR,
|
||||
description=f"File {uploadFile.filename} already exists in storage.",
|
||||
),
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail=f"File {uploadFile.filename} already exists in storage.",
|
||||
)
|
||||
else:
|
||||
notification_service.update_notification_by_id(
|
||||
upload_notification.id if upload_notification else None,
|
||||
NotificationUpdatableProperties(
|
||||
status=NotificationsStatusEnum.ERROR,
|
||||
description=f"There was an error uploading the file",
|
||||
),
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=500, detail=f"Failed to upload file to storage. {e}"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user