Improve windows terminal missing error message

This commit is contained in:
crschnick 2024-10-16 14:13:52 +00:00
parent 411e9c17b6
commit e80cf7e4b0

View file

@ -1,5 +1,6 @@
package io.xpipe.app.terminal; package io.xpipe.app.terminal;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.LocalShell; import io.xpipe.app.util.LocalShell;
import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.store.FileNames; import io.xpipe.core.store.FileNames;
@ -67,6 +68,10 @@ public interface WindowsTerminalType extends ExternalTerminalType {
@Override @Override
public void launch(LaunchConfiguration configuration) throws Exception { public void launch(LaunchConfiguration configuration) throws Exception {
if (!isAvailable()) {
throw ErrorEvent.expected(new IllegalArgumentException("Windows Terminal Preview is not installed"));
}
LocalShell.getShell() LocalShell.getShell()
.executeSimpleCommand( .executeSimpleCommand(
CommandBuilder.of().addFile(getPath().toString()).add(toCommand(configuration))); CommandBuilder.of().addFile(getPath().toString()).add(toCommand(configuration)));
@ -98,6 +103,10 @@ public interface WindowsTerminalType extends ExternalTerminalType {
@Override @Override
public void launch(LaunchConfiguration configuration) throws Exception { public void launch(LaunchConfiguration configuration) throws Exception {
if (!isAvailable()) {
throw ErrorEvent.expected(new IllegalArgumentException("Windows Terminal Canary is not installed"));
}
LocalShell.getShell() LocalShell.getShell()
.executeSimpleCommand( .executeSimpleCommand(
CommandBuilder.of().addFile(getPath().toString()).add(toCommand(configuration))); CommandBuilder.of().addFile(getPath().toString()).add(toCommand(configuration)));