fix: code execution error handling

This commit is contained in:
Timothy J. Baek 2024-05-16 19:30:09 -10:00
parent 4efb8638ff
commit 6dedf9885f

View File

@ -165,11 +165,16 @@
} }
}); });
result = pyodide.runPython(code); try {
result = pyodide.runPython(code);
console.log(result); console.log(result);
console.log(stdout); console.log(stdout);
console.log(stderr); console.log(stderr);
} catch (error) {
console.error('Error:', error);
stderr = error;
}
}; };
$: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : ''; $: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : '';