Skip to content

Commit 9afe012

Browse files
committed
Add process error output to revealFailedException
1 parent b374e21 commit 9afe012

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/java/org/cryptomator/linux/revealpath/DBusFileMangerRevealPath.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class DBusFileMangerRevealPath implements RevealPathService {
1919

2020
private static final String FOR_FOLDERS = "org.freedesktop.FileManager1.ShowFolders";
2121
private static final String FOR_FILES = "org.freedesktop.FileManager1.ShowItems";
22-
private static final int TIMEOUT_THRESHOLD=5000;
22+
private static final int TIMEOUT_THRESHOLD = 5000;
2323

2424
@Override
2525
public void reveal(Path path) throws RevealFailedException {
@@ -28,7 +28,7 @@ public void reveal(Path path) throws RevealFailedException {
2828
var uriPath = Arrays.stream(path.toUri().getPath().split("/")).map(s -> URLEncoder.encode(s, StandardCharsets.UTF_8).replace("+", "%20")).collect(Collectors.joining("/"));
2929
ProcessBuilder pb = new ProcessBuilder().command("dbus-send",
3030
"--print-reply",
31-
"--reply-timeout="+TIMEOUT_THRESHOLD,
31+
"--reply-timeout=" + TIMEOUT_THRESHOLD,
3232
"--dest=org.freedesktop.FileManager1",
3333
"--type=method_call",
3434
"/org/freedesktop/FileManager1",
@@ -37,10 +37,13 @@ public void reveal(Path path) throws RevealFailedException {
3737
"string:\"\""
3838
);
3939
var process = pb.start();
40-
if (process.waitFor(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS)) {
41-
int exitValue = process.exitValue();
42-
if (exitValue != 0) {
43-
throw new RevealFailedException("dbus-send returned with code" + exitValue);
40+
try (var reader = process.errorReader()) {
41+
if (process.waitFor(TIMEOUT_THRESHOLD, TimeUnit.MILLISECONDS)) {
42+
int exitValue = process.exitValue();
43+
if (process.exitValue() != 0) {
44+
String error = reader.lines().collect(Collectors.joining());
45+
throw new RevealFailedException("dbus-send exited with code " + exitValue + " and error message: " + error);
46+
}
4447
}
4548
}
4649
} catch (IOException e) {

0 commit comments

Comments
 (0)