Skip to content

Error handling#116

Open
Puh00 wants to merge 6 commits into
mainfrom
error-handling
Open

Error handling#116
Puh00 wants to merge 6 commits into
mainfrom
error-handling

Conversation

@Puh00

@Puh00 Puh00 commented May 21, 2022

Copy link
Copy Markdown
Owner

Made some changes here and there to make the LearnyPy less prone to errors. For instance the following code snippet didn't work before (when you run the entire program at once)

from collections import Counter
inventory = Counter()
loot = {"sword": 1, "bread": 3}
inventory.update(loot)
print(inventory)

Also added a try catch for dotGenerator so it doesn't crasch the web application. Tried writing a custom error message to the outputbox but was unable to since Skulpt was overwriting my message with some output that isn't really helpful for the user. Maybe someone else can have a look at it. My approach was to pass an extra parameter output_text to restart_callback() that by default has an empty string, which is later passed on to restart: skulpt.restart(prog, () => clear_visuals(output_text), false);. Then I modified the promise in skulpt.restart to this:

promise
  .then(this.debugger.success.bind(this.debugger), this.debugger.error.bind(this.debugger))
  .finally(() => {
    // call the callback function if it is a function
    if (typeof callback === 'function') {
      callback();
    }
  });

Even with the finally(... the debugger.error still overwrites the custom message passed in the callback function.

I'm also pretty sure that the issue with imports won't be easy to fix. Skulpt even state here that this is a known issue. I even found a master thesis that created their own debugger for skulpt and they also have the same issue (link to their web app). I've added this issue to the known limitations in the about page for now.

@netlify

netlify Bot commented May 21, 2022

Copy link
Copy Markdown

Deploy Preview for learnypy ready!

Name Link
🔨 Latest commit 2f1a353
🔍 Latest deploy log https://app.netlify.com/sites/learnypy/deploys/62953a7475929c0008bbe105
😎 Deploy Preview https://deploy-preview-116--learnypy.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Comment thread src/pages/About.js Outdated
<li>Many iterations will make the website slow.</li>
<li>Only Python 3.7.3 grammar is supported.</li>
<li>A few Python libraries are supported.</li>
<li>Debugger is unable to suspend correctly when importing Python modules.</li>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

noice! but this message might be a bit confusing for the average users, maybe something like "Importing Python modules might not always work correctly".

@moa114 moa114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm!

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