Skip to content

Commit 9c8c35f

Browse files
committed
handleRuntimeErrorをplainの関数にし、alertを追加
1 parent 5e9f65b commit 9c8c35f

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

app/terminal/exec.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import { useRuntime } from "@my-code/runtime/context";
1616
import { captureException } from "@sentry/nextjs";
1717
import { MinMaxButton, Modal } from "./modal";
1818

19+
function handleRuntimeError(error: unknown) {
20+
captureException(error);
21+
window.alert(
22+
"コード実行環境で予期せぬエラーが発生しました: \n" + String(error)
23+
);
24+
}
25+
1926
interface ExecProps {
2027
/*
2128
* Pythonの場合はメインファイル1つのみを指定する。
@@ -69,13 +76,7 @@ export function ExecFile(props: ExecProps) {
6976
`Language ${props.language.originalLang} does not have a runtime environment.`
7077
);
7178
}
72-
const handleRuntimeError = useCallback((error: unknown) => {
73-
if (error instanceof Error) {
74-
captureException(error);
75-
return;
76-
}
77-
captureException(new Error(String(error)));
78-
}, []);
79+
7980
const { ready, runFiles, getCommandlineStr, runtimeInfo, interrupt } =
8081
useRuntime(props.language.runtime, { onError: handleRuntimeError });
8182

app/terminal/repl.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ import { useRuntime } from "@my-code/runtime/context";
2727
import { MinMaxButton, Modal } from "./modal";
2828
import { StopButtonContent } from "./exec";
2929

30+
function handleRuntimeError(error: unknown) {
31+
captureException(error);
32+
window.alert(
33+
"コード実行環境で予期せぬエラーが発生しました: \n" + String(error)
34+
);
35+
}
36+
3037
export function writeOutput(
3138
term: Terminal,
3239
output: ReplOutput,
@@ -88,13 +95,6 @@ export function ReplTerminal({
8895
`Language ${language.originalLang} does not have a runtime environment.`
8996
);
9097
}
91-
const handleRuntimeError = useCallback((error: unknown) => {
92-
if (error instanceof Error) {
93-
captureException(error);
94-
return;
95-
}
96-
captureException(new Error(String(error)));
97-
}, []);
9898

9999
const {
100100
ready: runtimeReady,

0 commit comments

Comments
 (0)