psychojs
psychojs copied to clipboard
If we put the error handling code in a separate script we could catch syntax errors
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.
Do you mean refactoring PsychoJS._captureErrors()
? An example would be nice, thanks
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.
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.