Skip to content

Show alert on runtime error in CodeWorld runner#80

Merged
jvoigtlaender merged 4 commits into
fmidue:fmiduefrom
nimec01:runner-runtime-errors
May 21, 2026
Merged

Show alert on runtime error in CodeWorld runner#80
jvoigtlaender merged 4 commits into
fmidue:fmiduefrom
nimec01:runner-runtime-errors

Conversation

@nimec01
Copy link
Copy Markdown
Collaborator

@nimec01 nimec01 commented May 21, 2026

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.

@jvoigtlaender
Copy link
Copy Markdown
Member

About this:

There is also a button presented to the user that allows it to open the code in the editor.

If the code being run was of the form

{- OBFUSCATED
    eJxdkEF...
-}

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.?

@nimec01
Copy link
Copy Markdown
Collaborator Author

nimec01 commented May 21, 2026

About this:

There is also a button presented to the user that allows it to open the code in the editor.

If the code being run was of the form

{- OBFUSCATED
    eJxdkEF...
-}

what would show up in the code editor? The above snippet or the un-obfuscated code?

It would show the obfuscated code.

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.?

You have a point here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.didShowError flag to ensure only the first runtime error triggers a modal.
  • Extends window.h$errorMsg to 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.

Comment thread web/js/run.js
Comment on lines +199 to +210
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,
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread web/js/run.js
Comment thread web/js/run.js Outdated
@jvoigtlaender jvoigtlaender merged commit df862f2 into fmidue:fmidue May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants