Skip to content
Snippets Groups Projects
Commit 347ee165 authored by thucpn's avatar thucpn
Browse files

display error popup

parent 9599ce62
Branches
No related tags found
Loading
......@@ -4,7 +4,20 @@ import { useChat } from "ai/react";
import { getConfig } from "./utils";
export default function Page() {
const handler = useChat({ api: getConfig("CHAT_API") });
const handler = useChat({
api: getConfig("CHAT_API"),
onError: (error: unknown) => {
if (!(error instanceof Error)) throw error;
let errorMessage: string;
try {
errorMessage = JSON.parse(error.message).detail;
} catch (e) {
console.error(e);
errorMessage = error.message;
}
alert(errorMessage);
},
});
return (
<div className="flex h-screen items-center justify-center">
<ChatSection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment