Skip to content

Commit 29d0e0a

Browse files
committed
エラーハンドリングを改善し、unknown型のエラーを適切に処理するように修正
1 parent 8581fb7 commit 29d0e0a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/[docs_id]/chatForm.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ export function ChatForm() {
3030
throw new Error(data.response || "エラーが発生しました。");
3131
}
3232
setResponse(data.response);
33-
} catch (error: any) {
34-
setResponse(`エラー: ${error.message}`);
33+
} catch (error: unknown) {
34+
if (error instanceof Error) {
35+
setResponse(`エラー: ${error.message}`);
36+
} else {
37+
setResponse(`エラー: ${String(error)}`);
38+
}
3539
} finally {
3640
setIsLoading(false);
3741
}

0 commit comments

Comments
 (0)