kopia lustrzana https://github.com/vitorpamplona/amethyst
Presenting better error messages when the image upload fails.
rodzic
6662966ab3
commit
fce27c3c55
|
@ -123,14 +123,17 @@ class ImageUploader(val account: Account?) {
|
|||
client.newCall(request).enqueue(object : Callback {
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
try {
|
||||
check(response.isSuccessful)
|
||||
response.body.use { body ->
|
||||
val url = server.parseUrlFromSuccess(body.string(), authorizationToken)
|
||||
checkNotNull(url) {
|
||||
"There must be an uploaded image URL in the response"
|
||||
}
|
||||
if (response.isSuccessful) {
|
||||
response.body.use { body ->
|
||||
val url = server.parseUrlFromSuccess(body.string(), authorizationToken)
|
||||
checkNotNull(url) {
|
||||
"There must be an uploaded image URL in the response"
|
||||
}
|
||||
|
||||
onSuccess(url, contentType)
|
||||
onSuccess(url, contentType)
|
||||
}
|
||||
} else {
|
||||
onError(RuntimeException("Error Uploading image: ${response.code}"))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
|
Ładowanie…
Reference in New Issue