js: custom init (~~/.init.js): fail loudly on errors

Previously, loading ~~/.init.js was inside a try block, in order to
quietly ignore errors if the file doesn't exist.

However, that also prevented any real errors from showing up even when
the file does exist, and the script continued as if everything is OK,
while in fact the custom init script didn't complete correctly.

Now we first check if the file exists, and then load it without
try/catch, so that any error shows up normally (and abort the script).
This commit is contained in:
Avi Halachmi (:avih) 2021-09-30 18:04:27 +03:00
parent 2d348980cb
commit 6123e97e31
1 changed files with 3 additions and 3 deletions

View File

@ -771,7 +771,7 @@ g.mp_event_loop = function mp_event_loop() {
})(this)
try {
// let the user extend us, e.g. for updating mp.module_paths
// let the user extend us, e.g. by adding items to mp.module_paths
// (unlike e.g. read_file, file_info doesn't expand meta-paths)
if (mp.utils.file_info(mp.utils.get_user_path("~~/.init.js")))
require("~~/.init");
} catch(e) {}