Hi i require some guidance on how to deal with (e....
# arrow
t
Hi i require some guidance on how to deal with (e.g. catch) json parsing exceptions when making retrofit api calls using arrow retrofit apdapter
my calling code resembles this...
Copy code
private suspend fun actualWork(): Either<Any, Any> = either {
    val networkData = repository.pharmaDocumentsSearch(options = mapOf("text" to "*", "limitation.count" to "100")).tapLeft { networkError -> consumeNetworkError(workerName, networkError) }.bind()
    Either.catch { repository.database.documentSearchItemDAO().insertAsync(manufacture(networkData)) }.tapLeft { databaseError -> consumeDatabaseError(workerName, databaseError) }.bind()
}
and my error processing function is
Copy code
fun consumeNetworkError(caller: String, exception: CallError) {
    when (exception) {
        is HttpError -> doLogging { "$caller Network Http error :: ${exception.code} ${exception.message} ${exception.body}" }
        is IOError -> doLogging(exception.cause) { "$caller Network IO error" }
        is UnexpectedCallError -> doLogging(exception.cause) { "$caller Unexpected Network error" }
    }
}
which all works really nicely
however when a json parsing exception occurs i do not log any errors my
actualWork
function fails silently
here is the repositiry function
Copy code
override suspend fun pharmaDocumentsSearch(headers: Map<String, String>, options: Map<String, String>): Either<CallError, DocumentsSearch> =
    withContext(NETWORK) { service.pharmaDocumentsSearch(headers = HEADERS, options) }
so i need to "wrap" the network call in an outer
Copy code
Either.catch { }