Skip to content

Commit

Permalink
Unify predict errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lferran committed Nov 24, 2023
1 parent 9875755 commit c5b96a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion nucliadb/nucliadb/search/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ async def chat_knowledgebox_endpoint(
except LimitsExceededError as exc:
return HTTPClientError(status_code=exc.status_code, detail=exc.detail)
except predict.ProxiedPredictAPIError as err:
return HTTPClientError(status_code=503, detail=f"{err.status}: {err.detail}")
return HTTPClientError(
status_code=503,
detail=f"Chat service unavailable. {err.status}: {err.detail}",
)
except IncompleteFindResultsError:
return HTTPClientError(
status_code=529,
Expand Down
5 changes: 4 additions & 1 deletion nucliadb/nucliadb/search/api/v1/resource/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ async def resource_chat_endpoint(
except LimitsExceededError as exc:
return HTTPClientError(status_code=exc.status_code, detail=exc.detail)
except predict.ProxiedPredictAPIError as err:
return HTTPClientError(status_code=503, detail=f"{err.status}: {err.detail}")
return HTTPClientError(
status_code=503,
detail=f"Chat service unavailable. {err.status}: {err.detail}",
)
except IncompleteFindResultsError:
return HTTPClientError(
status_code=529,
Expand Down
5 changes: 4 additions & 1 deletion nucliadb/nucliadb/search/api/v1/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ async def summarize_endpoint(
except LimitsExceededError as exc:
return HTTPClientError(status_code=exc.status_code, detail=exc.detail)
except predict.ProxiedPredictAPIError as err:
return HTTPClientError(status_code=503, detail=f"{err.status}: {err.detail}")
return HTTPClientError(
status_code=503,
detail=f"Summarize service unavailable. {err.status}: {err.detail}",
)

0 comments on commit c5b96a3

Please sign in to comment.