Kristian Nedrevold
08/04/2022, 12:46 PMval responseData: ReservedCitizenResponse = response.body()
. If there is something wrong in the response body this will just crash with an JsonDecodingException as an unchecked exception. It would be nice if the .body() function returned a Result monad so you could handle the cases of successful and unsuccessful serialization.Kristian Nedrevold
08/04/2022, 1:02 PMval responseData: ReservedCitizenResponse = try {response.body() } catch (e: Exception) { return Result.failure(NHNInvalidResponseBodyException("Json response does not match expected fields\ne${e.message}")) }
This is how I have solved it for now, which is not very elegant, but does allow me to return early.Landry Norris
08/04/2022, 2:15 PM