Improve script init failure message

This commit is contained in:
crschnick 2023-12-28 00:57:06 +00:00
parent f689e6a2ea
commit f2c5561eac

View file

@ -31,18 +31,23 @@ public abstract class ScriptStore extends JacksonizedValue implements DataStore,
} }
public static ShellControl controlWithScripts(ShellControl pc, List<DataStoreEntryRef<ScriptStore>> initScripts, List<DataStoreEntryRef<ScriptStore>> bringScripts) { public static ShellControl controlWithScripts(ShellControl pc, List<DataStoreEntryRef<ScriptStore>> initScripts, List<DataStoreEntryRef<ScriptStore>> bringScripts) {
var initFlattened = flatten(initScripts); try {
var bringFlattened = flatten(bringScripts); var initFlattened = flatten(initScripts);
var bringFlattened = flatten(bringScripts);
pc.onInit(shellControl -> { pc.onInit(shellControl -> {
passInitScripts(pc, initFlattened); passInitScripts(pc, initFlattened);
var dir = initScriptsDirectory(shellControl, bringFlattened); var dir = initScriptsDirectory(shellControl, bringFlattened);
if (dir != null) { if (dir != null) {
shellControl.withInitSnippet(new SimpleScriptSnippet(shellControl.getShellDialect().appendToPathVariableCommand(dir), ScriptSnippet.ExecutionType.TERMINAL_ONLY)); shellControl.withInitSnippet(new SimpleScriptSnippet(shellControl.getShellDialect().appendToPathVariableCommand(dir),
} ScriptSnippet.ExecutionType.TERMINAL_ONLY));
}); }
return pc; });
return pc;
} catch (Throwable t) {
throw new RuntimeException("Unable to set up scripts", t);
}
} }
private static void passInitScripts(ShellControl pc, List<SimpleScriptStore> scriptStores) throws Exception { private static void passInitScripts(ShellControl pc, List<SimpleScriptStore> scriptStores) throws Exception {