mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-24 16:40:25 +00:00
Improve shell error messages
This commit is contained in:
parent
7390d3b25c
commit
52102bff31
2 changed files with 14 additions and 4 deletions
|
@ -8,6 +8,8 @@ public interface ShellDumbMode {
|
|||
return true;
|
||||
}
|
||||
|
||||
default void throwIfUnsupported() {}
|
||||
|
||||
default ShellDialect getSwitchDialect() {
|
||||
return null;
|
||||
}
|
||||
|
@ -25,6 +27,14 @@ public interface ShellDumbMode {
|
|||
|
||||
class Unsupported implements ShellDumbMode {
|
||||
|
||||
private final String message;
|
||||
|
||||
public Unsupported(String message) {this.message = message;}
|
||||
|
||||
public void throwIfUnsupported() {
|
||||
throw new UnsupportedOperationException(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAnyPossibleInteraction() {
|
||||
return false;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package io.xpipe.core.store;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.xpipe.core.process.CommandBuilder;
|
||||
import io.xpipe.core.process.ShellControl;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -37,9 +36,10 @@ public class ConnectionFileSystem implements FileSystem {
|
|||
@Override
|
||||
public FileSystem open() throws Exception {
|
||||
shellControl.start();
|
||||
if (!shellControl.getShellDialect().getDumbMode().supportsAnyPossibleInteraction()) {
|
||||
var d = shellControl.getShellDialect().getDumbMode();
|
||||
if (!d.supportsAnyPossibleInteraction()) {
|
||||
shellControl.close();
|
||||
throw new UnsupportedOperationException("System shell does not support file system interaction");
|
||||
d.throwIfUnsupported();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue