Errors in __init__.js are silenced
Thrown errors in a __init__.js
file are silenced, but only cause the script to stop parsing the rest of the file. Syntax errors in the script cause the entire script to be skipped.
// run with `GJS_PATH=. gjs test.js`
subdir/__init__.js
test.js
// subdir/__init__.js
throw new Error('early error');
var SOMETHING = 'something';
syntax error // this is a literal syntax error
throw new Error('late error');
var SOMETHING_ELSE = 'something else';
// test.js
log(imports.subdir.SOMETHING);
log(imports.subdir.SOMETHING_ELSE);
Notice if early error
is thrown, test.js
will error with:
JS ERROR: ImportError: No JS module 'SOMETHING' found in search path
If late error
is thrown, test.js
will error with:
JS LOG: something
JS ERROR: ImportError: No JS module 'SOMETHING_ELSE' found in search path
However, if the file contains a syntax error none of it will parsed. In all cases, __init__.js
reports no errors itself.
Edited by Andy Holmes