Add better error messages for integrations

This commit is contained in:
crschnick 2023-04-23 08:52:42 +00:00
parent 6ca4b056e7
commit b211e10184
2 changed files with 14 additions and 4 deletions

View file

@ -57,7 +57,10 @@ public class FileOpener {
try {
editor.launch(Path.of(file).toRealPath());
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEvent.fromThrowable(e)
.description("Unable to launch editor " + editor.toTranslatedString()
+ ". Maybe try to use a different one in the settings.")
.handle();
}
}
@ -71,11 +74,12 @@ public class FileOpener {
pc.executeSimpleCommand("open \"" + file + "\"");
}
} catch (Exception e) {
ErrorEvent.fromThrowable(e).handle();
ErrorEvent.fromThrowable(e)
.description("Unable to open file " + file).handle();
}
}
public static void openString(String keyName,Object key, String input, Consumer<String> output) {
public static void openString(String keyName, Object key, String input, Consumer<String> output) {
FileBridge.get().openString(keyName, key, input, output, file -> openInTextEditor(file));
}
}

View file

@ -4,6 +4,8 @@ import io.xpipe.app.core.AppI18n;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.CommandControl;
import java.io.IOException;
public class TerminalHelper {
public static void open(String title, CommandControl cc) throws Exception {
@ -21,6 +23,10 @@ public class TerminalHelper {
throw new IllegalStateException(AppI18n.get("noTerminalSet"));
}
type.launch(title, command, false);
try {
type.launch(title, command, false);
} catch (Exception ex) {
throw new IOException("Unable to launch terminal " + type.toTranslatedString() + ". Maybe try to use a different one in the settings.");
}
}
}