Skip to content

Commit 4a275c3

Browse files
committed
refactor: check response status while downloading svg
1 parent e5cb400 commit 4a275c3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/svg/octicons/data

tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/svg/octicons/data/OcticonsRepository.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.github.composegears.valkyrie.util.coroutines.suspendLazy
44
import io.ktor.client.HttpClient
55
import io.ktor.client.request.get
66
import io.ktor.client.statement.bodyAsText
7+
import io.ktor.http.isSuccess
78
import kotlinx.coroutines.Dispatchers
89
import kotlinx.coroutines.withContext
910
import kotlinx.serialization.json.Json
@@ -34,7 +35,11 @@ class OcticonsRepository(
3435
suspend fun loadMetadata(): List<OcticonsIconMetadata> = metadata()
3536

3637
suspend fun downloadSvg(path: String): String = withContext(Dispatchers.IO) {
37-
httpClient.get(resolveOcticonsSvgUrl(path, version = latestVersion())).bodyAsText()
38+
val response = httpClient.get(resolveOcticonsSvgUrl(path, version = latestVersion()))
39+
if (!response.status.isSuccess()) {
40+
error("Failed to download css.gg SVG: HTTP ${response.status.value}")
41+
}
42+
response.bodyAsText()
3843
}
3944

4045
private companion object {

0 commit comments

Comments
 (0)