aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/org/pacien/tincapp/commands/Executor.kt10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
index 6fe7c4c..7630b61 100644
--- a/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
+++ b/app/src/main/java/org/pacien/tincapp/commands/Executor.kt
@@ -57,10 +57,11 @@ internal object Executor {
57 } 57 }
58 58
59 return runAsyncTask { 59 return runAsyncTask {
60 when (wait(pid)) { 60 val exitCode = wait(pid)
61 when (exitCode) {
61 SUCCESS -> Unit 62 SUCCESS -> Unit
62 FAILED -> throw CommandExecutionException("Process terminated abnormally.") 63 FAILED -> throw CommandExecutionException("Process terminated abnormally.")
63 else -> throw CommandExecutionException("Non-zero exit status code.") 64 else -> throw CommandExecutionException("Non-zero exit status code ($exitCode).")
64 } 65 }
65 } 66 }
66 } 67 }
@@ -73,8 +74,9 @@ internal object Executor {
73 74
74 fun call(cmd: Command): CompletableFuture<List<String>> = run(cmd).let { process -> 75 fun call(cmd: Command): CompletableFuture<List<String>> = run(cmd).let { process ->
75 supplyAsyncTask<List<String>> { 76 supplyAsyncTask<List<String>> {
76 if (process.waitFor() == 0) read(process.inputStream) 77 val exitCode = process.waitFor()
77 else throw CommandExecutionException(read(process.errorStream).lastOrNull() ?: "Non-zero exit status.") 78 if (exitCode == 0) read(process.inputStream)
79 else throw CommandExecutionException(read(process.errorStream).lastOrNull() ?: "Non-zero exit status ($exitCode).")
78 } 80 }
79 } 81 }
80 82