diff --git a/pyscript.core/src/plugins/py-editor.js b/pyscript.core/src/plugins/py-editor.js index 3c27192c..3d032c53 100644 --- a/pyscript.core/src/plugins/py-editor.js +++ b/pyscript.core/src/plugins/py-editor.js @@ -1,6 +1,7 @@ // PyScript py-editor plugin import { Hook, XWorker, dedent, defineProperties } from "polyscript/exports"; import { TYPES, offline_interpreter, relative_url, stdlib } from "../core.js"; +import { notify } from "./error.js"; const RUN_BUTTON = ``; @@ -87,10 +88,14 @@ async function execute({ currentTarget }) { const { sync } = xworker; sync.write = (str) => { if (hasRunButton) outDiv.innerText += `${str}\n`; + else console.log(str); }; sync.writeErr = (str) => { if (hasRunButton) { outDiv.innerHTML += `${str}\n`; + } else { + notify(str); + console.error(str); } }; sync.runAsync(pySrc).then(enable, enable); diff --git a/pyscript.core/test/issue-2093/error.js b/pyscript.core/test/issue-2093/error.js new file mode 100644 index 00000000..e7dd853a --- /dev/null +++ b/pyscript.core/test/issue-2093/error.js @@ -0,0 +1,6 @@ +const { error } = console; + +console.error = (...args) => { + error(...args); + document.documentElement.classList.add('errored'); +}; diff --git a/pyscript.core/test/issue-2093/index.html b/pyscript.core/test/issue-2093/index.html new file mode 100644 index 00000000..293078fb --- /dev/null +++ b/pyscript.core/test/issue-2093/index.html @@ -0,0 +1,16 @@ + + +
+ + + + + + + + + + diff --git a/pyscript.core/test/mpy.spec.js b/pyscript.core/test/mpy.spec.js index c740f4f9..ba1556ea 100644 --- a/pyscript.core/test/mpy.spec.js +++ b/pyscript.core/test/mpy.spec.js @@ -98,3 +98,8 @@ test('MicroPython + workers', async ({ page }) => { await page.goto('http://localhost:8080/test/workers/index.html'); await page.waitForSelector('html.mpy.py'); }); + +test('MicroPython Editor setup error', async ({ page }) => { + await page.goto('http://localhost:8080/test/issue-2093/index.html'); + await page.waitForSelector('html.errored'); +});