Improve shell error messages

This commit is contained in:
crschnick 2024-08-03 01:50:04 +00:00
parent 7390d3b25c
commit 52102bff31
2 changed files with 14 additions and 4 deletions

View file

@ -8,6 +8,8 @@ public interface ShellDumbMode {
return true; return true;
} }
default void throwIfUnsupported() {}
default ShellDialect getSwitchDialect() { default ShellDialect getSwitchDialect() {
return null; return null;
} }
@ -25,6 +27,14 @@ public interface ShellDumbMode {
class Unsupported implements ShellDumbMode { class Unsupported implements ShellDumbMode {
private final String message;
public Unsupported(String message) {this.message = message;}
public void throwIfUnsupported() {
throw new UnsupportedOperationException(message);
}
@Override @Override
public boolean supportsAnyPossibleInteraction() { public boolean supportsAnyPossibleInteraction() {
return false; return false;

View file

@ -1,9 +1,8 @@
package io.xpipe.core.store; package io.xpipe.core.store;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.process.CommandBuilder;
import io.xpipe.core.process.ShellControl; import io.xpipe.core.process.ShellControl;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.Getter;
import java.io.InputStream; import java.io.InputStream;
@ -37,9 +36,10 @@ public class ConnectionFileSystem implements FileSystem {
@Override @Override
public FileSystem open() throws Exception { public FileSystem open() throws Exception {
shellControl.start(); shellControl.start();
if (!shellControl.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) { var d = shellControl.getShellDialect().getDumbMode();
if (!d.supportsAnyPossibleInteraction()) {
shellControl.close(); shellControl.close();
throw new UnsupportedOperationException("System shell does not support file system interaction"); d.throwIfUnsupported();
} }
return this; return this;
} }