From 0b8608016693aad1cc9800d34c5b1ebf6c10def7 Mon Sep 17 00:00:00 2001 From: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Date: Wed, 26 Jul 2023 23:59:34 +0530 Subject: [PATCH] fix: displaying API error for AI response (#1677) --- apps/app/components/core/modals/gpt-assistant-modal.tsx | 5 ++++- apps/app/components/issues/form.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/app/components/core/modals/gpt-assistant-modal.tsx b/apps/app/components/core/modals/gpt-assistant-modal.tsx index f1b24c65b..7c05e036a 100644 --- a/apps/app/components/core/modals/gpt-assistant-modal.tsx +++ b/apps/app/components/core/modals/gpt-assistant-modal.tsx @@ -117,18 +117,21 @@ export const GptAssistantModal: React.FC = ({ else setInvalidResponse(false); }) .catch((err) => { + const error = err?.data?.error; + if (err.status === 429) setToastAlert({ type: "error", title: "Error!", message: + error || "You have reached the maximum number of requests of 50 requests per month per user.", }); else setToastAlert({ type: "error", title: "Error!", - message: "Some error occurred. Please try again.", + message: error || "Some error occurred. Please try again.", }); }); }; diff --git a/apps/app/components/issues/form.tsx b/apps/app/components/issues/form.tsx index 1a87ac9fe..e6fc11ae2 100644 --- a/apps/app/components/issues/form.tsx +++ b/apps/app/components/issues/form.tsx @@ -202,18 +202,21 @@ export const IssueForm: FC = ({ else handleAiAssistance(res.response_html); }) .catch((err) => { + const error = err?.data?.error; + if (err.status === 429) setToastAlert({ type: "error", title: "Error!", message: + error || "You have reached the maximum number of requests of 50 requests per month per user.", }); else setToastAlert({ type: "error", title: "Error!", - message: "Some error occurred. Please try again.", + message: error || "Some error occurred. Please try again.", }); }) .finally(() => setIAmFeelingLucky(false));