Skip to content

Commit

Permalink
Merge pull request #100 from metaplex-foundation/martini/network-driv…
Browse files Browse the repository at this point in the history
…er-error-handling

Add bare bones error handling to network driver
  • Loading branch information
ajamaica authored Feb 6, 2023
2 parents 3b92537 + 95a84d5 commit 19a8410
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ class JdkHttpDriver : HttpNetworkDriver {
}

// read response
val responseString = inputStream.bufferedReader().use { it.readText() }
val response = (inputStream ?: errorStream)?.bufferedReader()?.use {
it.readText()
}?.let { responseString -> Result.success(responseString) }
?: Result.failure(Throwable("No Response"))

// TODO: should check response code and/or errorStream for errors
// println("URL : $url")
// println("Response Code : $responseCode")
// println("input stream : $responseString")

continuation.resumeWith(Result.success(responseString))
continuation.resumeWith(response)
}
}
}

0 comments on commit 19a8410

Please sign in to comment.