Skip to content

Commit 988b915

Browse files
author
chenwenhao.427
committed
fix(chat): fix undefined access in weather error rendering
1 parent 22de923 commit 988b915

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

components/message.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,19 @@ const PurePreviewMessage = ({
176176
const widthClass = "w-[min(100%,450px)]";
177177

178178
if (state === "output-available") {
179+
const output = part.output as any;
180+
181+
if (output && "error" in output) {
182+
return (
183+
<div
184+
className="rounded-lg border border-red-200 bg-red-50 p-4 text-red-500 dark:bg-red-950/50"
185+
key={toolCallId}
186+
>
187+
Error getting weather: {String(output.error)}
188+
</div>
189+
);
190+
}
191+
179192
return (
180193
<div className={widthClass} key={toolCallId}>
181194
<Weather weatherAtLocation={part.output} />

0 commit comments

Comments
 (0)