Skip to content

Commit 8342a21

Browse files
committed
fix: raise the original error when cli can't be downloaded
1 parent bce103b commit 8342a21

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.coder.toolbox.cli
33
import com.coder.toolbox.CoderToolboxContext
44
import com.coder.toolbox.cli.downloader.CoderDownloadApi
55
import com.coder.toolbox.cli.downloader.CoderDownloadService
6+
import com.coder.toolbox.cli.downloader.DownloadResult
67
import com.coder.toolbox.cli.downloader.DownloadResult.Downloaded
78
import com.coder.toolbox.cli.ex.MissingVersionException
89
import com.coder.toolbox.cli.ex.SSHConfigFormatException
@@ -168,7 +169,8 @@ class CoderCLIManager(
168169
}.let { result ->
169170
when {
170171
result.isSkipped() -> return false
171-
result.isNotFoundOrFailed() -> throw IllegalStateException("Could not find or download Coder CLI")
172+
result.isNotFound() -> throw IllegalStateException("Could not find Coder CLI")
173+
result.isFailed() -> throw (result as DownloadResult.Failed).error
172174
else -> result as Downloaded
173175
}
174176
}

src/main/kotlin/com/coder/toolbox/cli/downloader/DownloadResult.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ sealed class DownloadResult {
1515

1616
fun isSkipped(): Boolean = this is Skipped
1717

18-
fun isNotFoundOrFailed(): Boolean = this is NotFound || this is Failed
18+
fun isNotFound(): Boolean = this is NotFound
19+
20+
fun isFailed(): Boolean = this is Failed
1921

2022
fun isDownloaded(): Boolean = this is Downloaded
2123

0 commit comments

Comments
 (0)