Skip to content

Commit 8ad4ddf

Browse files
Merge pull request #304 from appwrite/fix-android-exceptions
Fix android exceptions
2 parents 5740a58 + cbe7e1f commit 8ad4ddf

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

templates/android/library/src/main/java/io/appwrite/Client.kt.twig

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,11 @@ class Client @JvmOverloads constructor(
314314

315315
val contentType: String = response.headers["content-type"] ?: ""
316316
val error = if (contentType.contains("application/json", ignoreCase = true)) {
317-
bodyString.fromJson<{{ spec.title | caseUcfirst }}Exception>()
317+
bodyString.fromJson()
318318
} else {
319319
{{ spec.title | caseUcfirst }}Exception(bodyString, response.code)
320320
}
321-
322-
it.cancel(AppwriteException(
323-
error.message,
324-
error.code,
325-
bodyString
326-
))
321+
it.cancel(error)
327322
}
328323
it.resume(response)
329324
}

templates/android/library/src/main/java/io/appwrite/exceptions/Exception.kt.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package {{ sdk.namespace | caseDot }}.exceptions
33
import java.lang.Exception
44

55
class {{spec.title | caseUcfirst}}Exception(
6-
message: String? = null,
6+
override val message: String? = null,
77
val code: Int? = null,
88
val response: String? = null
99
) : Exception(message)

tests/SDKTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class SDKTest extends TestCase
7979
'envs' => [
8080
'java-8' => 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/android alvrme/alpine-android:latest-jdk8 sh -c "./gradlew :library:testReleaseUnitTest -q && cat library/result.txt"',
8181
],
82-
'supportException' => false,
82+
'supportException' => true,
8383
'supportRealtime' => true,
8484
],
8585

0 commit comments

Comments
 (0)