Good morning everyone, I’m using Ktor-client on a...
# ktor
d
Good morning everyone, I’m using Ktor-client on a multiplatform project, I created an
Either
class, similar to the one from Arrow-kt. I’d like to know if is possible to create a “converter” for it. Thank you
j
I am interested too, I was tried some time ago and I couldn't
d
Best thing I found so far is https://ktor.io/docs/response-validation.html#configuration Usage example
Copy code
class EitherException(val reason: Error)

when {
  xxx -> throw EitherException(Xxx)
  yyy -> throw EitherException(Yyy)

// Either.Compaion
fun Try(block: () -> T) =
  try { 
    Right(...)
  } catch (e: EitherException) 
    Left(...)
  }

fun login(...) = 
  Either.Try { <http://client.post|client.post>(...) }
j
Yeah that can be a workaround but I would like to create a feature similar I did with Retrofit and an adapter
d