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

display error popup

parent 9599ce62
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,20 @@ import { useChat } from "ai/react"; ...@@ -4,7 +4,20 @@ import { useChat } from "ai/react";
import { getConfig } from "./utils"; import { getConfig } from "./utils";
export default function Page() { 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 ( return (
<div className="flex h-screen items-center justify-center"> <div className="flex h-screen items-center justify-center">
<ChatSection <ChatSection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment