-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Handling #12
Comments
At an absolute bare minimum we should be able to catch an error and offer to reset to a usable state. At a glance, anything beyond that (did you mean..., etc.) would be totally custom. I'll think on it though. On the plus side, semicolons are optional in Javascript. |
I've done a bit more work on this. As it stands, I can catch an error without any trouble. The problem is that the error I catch is a Javascript error, not a Processing error, which can get a little confusing. Here's the current behavior:
My worry here is that constant pop-ups will get annoying over time, but the window doesn't have to be full-screen modal. We can show the same thing under the editor or elsewhere. Most of the work here, I think, would be tons of regular expressions trying to make friendly errors. The other option is to try to parse the Processing code for errors before compiling it to JS, though I think that's an even bigger project. -S |
@scottgarner I'm not seeing the error window for some reason. This is the code I'm testing with:
|
Wow, that was almost a huge problem! I had only been testing cases without the draw() loop for errors. It didn't occur to me that with the draw, the code is called anonymously by a timer, making it almost impossible to catch errors without reworking parts of processing.js. I lucked out on a simple fix, which is to manually call draw inside of my try {} when it's available. After quick testing it seems okay, but it's definitely something to keep an eye on. |
Current status for this: There is a displayError() function in editor.js which takes a Javascript error and has some initial code to search for common problems and report them in a friendlier way. I'd like to think of a tidier way to do this, but it works for now. I'm going to assign this to @shiffman for now and work with him to catch common errors and streamline any other aspects of the error system that need work. |
Great, I'll take a closer look at this sometime this week. |
I've got an idea for a simple translation table. I'll take a quick stab at it and you can let me know if you have any questions when you get a chance. |
Okay, I've added an error translation table with a few examples. Let me know if you have any questions. |
Something just occurred to me: Every javascript engine is going to throw its own version of the errors and they'll probably all vary slightly. |
Taking this off of the milestones leading to launch and marking it as an enhancement. |
Just adding an issue to open the discussion on how to handle syntax errors in code. Some thoughts:
The text was updated successfully, but these errors were encountered: