Skip to content

Commit 424aa9b

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

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

app/terminal/exec.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ 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("コード実行環境で予期せぬエラーが発生しました: " + String(error));
22+
}
23+
1924
interface ExecProps {
2025
/*
2126
* Pythonの場合はメインファイル1つのみを指定する。
@@ -69,13 +74,7 @@ export function ExecFile(props: ExecProps) {
6974
`Language ${props.language.originalLang} does not have a runtime environment.`
7075
);
7176
}
72-
const handleRuntimeError = useCallback((error: unknown) => {
73-
if (error instanceof Error) {
74-
captureException(error);
75-
return;
76-
}
77-
captureException(new Error(String(error)));
78-
}, []);
77+
7978
const { ready, runFiles, getCommandlineStr, runtimeInfo, interrupt } =
8079
useRuntime(props.language.runtime, { onError: handleRuntimeError });
8180

app/terminal/repl.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ 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("コード実行環境で予期せぬエラーが発生しました: " + String(error));
33+
}
34+
3035
export function writeOutput(
3136
term: Terminal,
3237
output: ReplOutput,
@@ -88,13 +93,6 @@ export function ReplTerminal({
8893
`Language ${language.originalLang} does not have a runtime environment.`
8994
);
9095
}
91-
const handleRuntimeError = useCallback((error: unknown) => {
92-
if (error instanceof Error) {
93-
captureException(error);
94-
return;
95-
}
96-
captureException(new Error(String(error)));
97-
}, []);
9896

9997
const {
10098
ready: runtimeReady,

0 commit comments

Comments
 (0)