hi guys. sorry for this very simple question. I've just started using Retrofit and I discovered Arrow last week, so I wanted to ask you a little tip. I have a retrofit api called getUser. Would it make sense to use Either in this way?
class CustomError {
data class RetrofitError(val error: Throwable) : CustomError()
// Add other custom errors if needed
}
suspend fun getUser(): Either<CustomError, User> {
return try {
val response: Response<User> = retrofitApi.getUser()
if (response.isSuccessful) {
response.body()?.right() ?: CustomError.RetrofitError(Throwable("No user found")).left()
} else {
CustomError.RetrofitError(Throwable("Response not successful")).left()
}
} catch (e: Exception) {
CustomError.RetrofitError(e).left()
}
}