fix: displaying API error for AI response (#1677)

This commit is contained in:
Dakshesh Jain 2023-07-26 23:59:34 +05:30 committed by GitHub
parent 0e352b7bcb
commit 0b86080166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -117,18 +117,21 @@ export const GptAssistantModal: React.FC<Props> = ({
else setInvalidResponse(false); else setInvalidResponse(false);
}) })
.catch((err) => { .catch((err) => {
const error = err?.data?.error;
if (err.status === 429) if (err.status === 429)
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: message:
error ||
"You have reached the maximum number of requests of 50 requests per month per user.", "You have reached the maximum number of requests of 50 requests per month per user.",
}); });
else else
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: "Some error occurred. Please try again.", message: error || "Some error occurred. Please try again.",
}); });
}); });
}; };

View File

@ -202,18 +202,21 @@ export const IssueForm: FC<IssueFormProps> = ({
else handleAiAssistance(res.response_html); else handleAiAssistance(res.response_html);
}) })
.catch((err) => { .catch((err) => {
const error = err?.data?.error;
if (err.status === 429) if (err.status === 429)
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: message:
error ||
"You have reached the maximum number of requests of 50 requests per month per user.", "You have reached the maximum number of requests of 50 requests per month per user.",
}); });
else else
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
message: "Some error occurred. Please try again.", message: error || "Some error occurred. Please try again.",
}); });
}) })
.finally(() => setIAmFeelingLucky(false)); .finally(() => setIAmFeelingLucky(false));