psychojs icon indicating copy to clipboard operation
psychojs copied to clipboard

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

Open tpronk opened this issue 3 years ago • 3 comments

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.

tpronk avatar May 17 '21 13:05 tpronk

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

thewhodidthis avatar May 17 '21 14:05 thewhodidthis

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

  • One JS-file contains script that catches the error (catch_error.js)
  • Another JS-file contains script that has a syntax error (trigger_error.js)

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

tpronk avatar May 17 '21 15:05 tpronk

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.

tpronk avatar May 17 '21 15:05 tpronk