error message for insufficient quota

This commit is contained in:
Jing Hua 2023-03-07 07:35:10 +08:00
parent 1142e9d973
commit 98729351e0
2 changed files with 9 additions and 3 deletions

View file

@ -39,7 +39,13 @@ export const getChatCompletionStream = async (
stream: true,
}),
});
if (!response.ok) throw new Error(await response.text());
const text = await response.text();
if (response.status === 429 && text.includes('insufficient_quota'))
throw new Error(
text +
'\nMessage from freechatgpt.chat:\nWe recommend changing your API endpoint or API key'
);
if (!response.ok) throw new Error(text);
const stream = response.body;
return stream;

View file

@ -60,8 +60,8 @@ const ChatContent = () => {
/>
{error !== '' && (
<div className='relative bg-red-600/50 p-2 rounded-sm w-3/5 mt-3'>
<div className='text-gray-900 dark:text-gray-300 text-sm break-words'>
<div className='relative bg-red-600/50 p-2 rounded-sm w-3/5 mt-3 max-md:w-11/12'>
<div className='text-gray-900 dark:text-gray-300 text-sm whitespace-pre-line'>
{error}
</div>
<div