Skip to content

Commit a9c6a1f

Browse files
committed
remove old either call
1 parent 2765bdb commit a9c6a1f

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

cli/src/main/kotlin/CliViewModel.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import arrow.core.continuations.either
21
import arrow.core.getOrElse
3-
import arrow.core.getOrHandle
2+
import arrow.core.raise.either
43
import client.ScryfallApi
54
import com.mfriend.collection.CollectionImporter
65
import com.mfriend.db.Card
@@ -34,7 +33,7 @@ class CliViewModel(
3433
}
3534
return@either cardRows.size
3635
}
37-
succ.getOrHandle { throw Exception(it) }
36+
succ.getOrElse { throw Exception(it) }
3837
}
3938

4039
suspend fun searchAndAddCards(query: String) {

scryfall/src/commonMain/kotlin/client/ScryfallApi.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import arrow.core.Either
44
import arrow.core.left
55
import arrow.core.right
66
import co.touchlab.kermit.Logger
7-
import models.CardDto
87
import io.ktor.client.call.body
98
import io.ktor.client.request.HttpRequestBuilder
109
import io.ktor.client.request.get
1110
import io.ktor.client.request.parameter
1211
import io.ktor.client.statement.HttpResponse
1312
import io.ktor.http.encodedPath
1413
import io.ktor.http.takeFrom
14+
import models.CardDto
1515
import models.ListResp
1616
import models.SetDto
1717

@@ -21,11 +21,10 @@ interface ScryfallApi {
2121
suspend fun sets(): Either<String, List<SetDto>>
2222
}
2323

24-
suspend inline fun <reified T> HttpResponse.toEither(): Either<String, T> =
25-
when (this.status.value) {
26-
in 200..299 -> this.body<T>().right()
27-
else -> this.body<String>().left()
28-
}
24+
suspend inline fun <reified T> HttpResponse.toEither(): Either<String, T> = when (this.status.value) {
25+
in 200..299 -> this.body<T>().right()
26+
else -> this.body<String>().left()
27+
}
2928

3029
class ScryfallApiImpl : ScryfallApi {
3130
private val client = newKtorClient()
@@ -72,4 +71,4 @@ class ScryfallApiImpl : ScryfallApi {
7271
encodedPath = path
7372
}
7473
}
75-
}
74+
}

0 commit comments

Comments
 (0)