Skip to content

Commit

Permalink
Handle 429 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckoates committed Jul 5, 2024
1 parent 7b22ac4 commit 3858280
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ export default function Home() {
);

if (!response.ok || !transcript || !text || !response.body) {
const error = (await response.text()) || "An error occurred.";
toast.error(error);
if (response.status === 429) {
toast.error("Too many requests. Please try again later.");
} else {
toast.error((await response.text()) || "An error occurred.");
}

return prevMessages;
}

Expand Down

0 comments on commit 3858280

Please sign in to comment.