Attila Domokos
11/02/2019, 8:23 PMTry is deprecated and going away, but what would be the most clear fix of this code:
fun extractUserInfo(userInfoData: String): Either<AppError, UserInfo> =
Try { createKlaxon().parse<UserInfo>(userInfoData) }
.toEither { AppError.UserDataJsonParseFailed("Couldn't parse") }
.leftIfNull { AppError.UserDataJsonParseFailed("Parsed result is null") }
Using try catch is doable, but painful to look at. The documentation still has reference of Try, but not what to do when I want to replace it with something else.