Show alert on runtime error in CodeWorld runner#80
Conversation
|
About this:
If the code being run was of the form what would show up in the code editor? The above snippet or the un-obfuscated code? The latter would be somewhat counter to the purpose of using obfuscated snippets in the first place (even though it will only happen on erroneous code; but maybe there will be a way to trick around this, like adding erroneous code alongside the obfuscated bit). The former would look weird and not be useful to the student. So maybe that button should not appear when "in obfuscated mode"? And actually, I am not sure what the use case of that button is. When the code was posted from Autotool via the "only-display-the-running-result" button, and then it turns out the code is buggy, well, why shouldn't the student continue working in Autotool's editor field, submitting code to the compiler there, etc.? |
It would show the obfuscated code.
You have a point here. |
There was a problem hiding this comment.
Pull request overview
Adds a runtime-error alert to the CodeWorld runner so that, when the runner is opened standalone (not embedded in the editor), the user sees the first runtime error in a SweetAlert dialog.
Changes:
- Introduces a
window.didShowErrorflag to ensure only the first runtime error triggers a modal. - Extends
window.h$errorMsgto display a SweetAlert dialog with a sanitized error message when the runner is top-level.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sweetAlert({ | ||
| title: 'A runtime error occurred in your program.', | ||
| html: `<pre style="text-align: left;">${sanitizedMessage}</pre>`, | ||
| width: "fit-content", | ||
| type: 'error', | ||
| showConfirmButton: false, | ||
| showCancelButton: false, | ||
| showCloseButton: false, | ||
| allowOutsideClick: false, | ||
| allowEscapeKey: false, | ||
| allowEnterKey: false, | ||
| }); |
There was a problem hiding this comment.
Well, I guess we want the user be "trapped" there, that is, they will have to close the browser tab since there is nothing else to do anyway?
The CodeWorld runner now shows the first runtime error reported. This alert is only shown when the runner is not embedded on another page (i.e. it does not show the error twice on the editor page).
There is also a button presented to the user that allows it to open the code in the editor.