From 6123e97e318122e128b4c034f897e8a82840a067 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Thu, 30 Sep 2021 18:04:27 +0300 Subject: 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). --- player/javascript/defaults.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index 6a1c0762d4..4393925efe 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -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) {} -- cgit v1.2.3