diff --git a/app/src/main/java/io/xpipe/app/core/check/AppShellCheck.java b/app/src/main/java/io/xpipe/app/core/check/AppShellCheck.java index ac5b58b3a..3d0180a51 100644 --- a/app/src/main/java/io/xpipe/app/core/check/AppShellCheck.java +++ b/app/src/main/java/io/xpipe/app/core/check/AppShellCheck.java @@ -5,6 +5,7 @@ import io.xpipe.app.util.LocalShell; import io.xpipe.core.process.OsType; import io.xpipe.core.process.ProcessControlProvider; import io.xpipe.core.process.ProcessOutputException; +import lombok.Value; import java.util.Optional; @@ -17,15 +18,19 @@ public class AppShellCheck { .getEffectiveLocalDialect() .equals(ProcessControlProvider.get().getFallbackDialect()); if (err.isPresent() && canFallback) { - var msg = formatMessage(err.get()); + var msg = formatMessage(err.get().getMessage()); ErrorEvent.fromThrowable(new IllegalStateException(msg)).handle(); enableFallback(); err = selfTestErrorCheck(); } if (err.isPresent()) { - var msg = formatMessage(err.get()); - ErrorEvent.fromThrowable(new IllegalStateException(msg)).handle(); + var msg = formatMessage(err.get().getMessage()); + var event = ErrorEvent.fromThrowable(new IllegalStateException(msg)); + if (!err.get().isCanContinue()) { + event.term(); + } + event.handle(); } } @@ -71,17 +76,24 @@ public class AppShellCheck { LocalShell.init(); } - private static Optional selfTestErrorCheck() { + private static Optional selfTestErrorCheck() { try (var command = LocalShell.getShell().command("echo test").complex().start()) { var out = command.readStdoutOrThrow(); if (!out.equals("test")) { - return Optional.of("Expected \"test\", got \"" + out + "\""); + return Optional.of(new FailureResult("Expected \"test\", got \"" + out + "\"", true)); } } catch (ProcessOutputException ex) { - return Optional.of(ex.getOutput() != null ? ex.getOutput() : ex.toString()); + return Optional.of(new FailureResult(ex.getOutput() != null ? ex.getOutput() : ex.toString(), true)); } catch (Throwable t) { - return Optional.of(t.getMessage() != null ? t.getMessage() : t.toString()); + return Optional.of(new FailureResult(t.getMessage() != null ? t.getMessage() : t.toString(), false)); } return Optional.empty(); } + + @Value + private static class FailureResult { + + String message; + boolean canContinue; + } } diff --git a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java index 9099461b9..3359ce6cb 100644 --- a/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java +++ b/app/src/main/java/io/xpipe/app/issue/SentryErrorHandler.java @@ -82,7 +82,7 @@ public class SentryErrorHandler implements ErrorHandler { causeField.set(copy, adjustCopy(throwable.getCause(), true)); return copy; - } catch (Exception e) { + } catch (Throwable e) { // This can fail for example when the underlying exception is not serializable // and comes from some third party library if (AppLogs.get() != null) { diff --git a/core/src/main/java/io/xpipe/core/process/ShellDialects.java b/core/src/main/java/io/xpipe/core/process/ShellDialects.java index a471f0d39..68893c8bd 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellDialects.java +++ b/core/src/main/java/io/xpipe/core/process/ShellDialects.java @@ -27,6 +27,7 @@ public class ShellDialects { public static ShellDialect CISCO; public static ShellDialect MIKROTIK; public static ShellDialect RBASH; + public static ShellDialect CONSTRAINED_POWERSHELL; public static ShellDialect OVH_BASTION; public static List getStartableDialects() { @@ -85,6 +86,7 @@ public class ShellDialects { CISCO = byId("cisco"); MIKROTIK = byId("mikrotik"); RBASH = byId("rbash"); + CONSTRAINED_POWERSHELL = byId("constrainedPowershell"); OVH_BASTION = byId("ovhBastion"); } }