psychopy / psychojs

PsychoJS is the online counterpart of the PsychoPy Python library
MIT License
165 stars 68 forks source link

If we put the error handling code in a separate script we could catch syntax errors #336

Open tpronk opened 3 years ago

tpronk commented 3 years ago

In that case, instead of the "Experiment is initialising..." text that participants see now, they could get an error message similar to the ones presented on a semantic error.

thewhodidthis commented 3 years ago

Do you mean refactoring PsychoJS._captureErrors()? An example would be nice, thanks

tpronk commented 3 years ago

It would require some refactoring yes. Example: catch_syntax error.zip.

Because both files are included (and evaluated) separately, the syntax error can be caught this way.

tpronk commented 3 years ago

The counterexample is this demo: https://gitlab.pavlovia.org/tpronk/tutorial_js_syntax_error

I think that, because the error catching is part of the module that gets imported by this experiment-script (which contains a syntax error), nothing gets evaluated at all, so the error catching doesn't work.