History

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).

Avi Halachmi (:avih) committed 5 years ago

Commit 6123e971 parent 2d348981 file · +3 −3Browse files

Showing the changes to player/javascript (1 of 1 file). Show all

Unified · Split

player/javascript/defaults.js+3−3
@@ -771,7 +771,7 @@ g.mp_event_loop = function mp_event_loop() { · 770 unmodified lines
771 771
772})(this)772})(this)
773 773
774try {774// let the user extend us, e.g. by adding items to mp.module_paths
775 // let the user extend us, e.g. for updating mp.module_paths775// (unlike e.g. read_file, file_info doesn't expand meta-paths)
776if (mp.utils.file_info(mp.utils.get_user_path("~~/.init.js")))
776 require("~~/.init");777 require("~~/.init");
777} catch(e) {}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t