Kulwinder Singh
01/05/2019, 8:01 AMextension
function await
to get document from firestore database. But when i'm using it like below, exception is thrown and my crashessashjakk
01/05/2019, 8:07 AMThrowable
instead of Exception
Kulwinder Singh
01/05/2019, 8:12 AMThrowable
but still app is crashingDico
01/05/2019, 8:37 AMKulwinder Singh
01/05/2019, 9:14 AMcom.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
at com.google.android.gms.tasks.zzu.getResult(Unknown Source:15)
at com.arkatech.common.FirebaseKt$await$2$1.onComplete(firebase.kt:101)
at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
Dico
01/05/2019, 9:20 AMKulwinder Singh
01/05/2019, 9:21 AMcatch
block is not catching this exceptionDico
01/05/2019, 9:23 AMresult.result
throwing it when it's not successful.Kulwinder Singh
01/05/2019, 10:04 AMsuspend fun <T> Task<T>.await(): T = suspendCancellableCoroutine { continuation ->
this.addOnSuccessListener(continuation::resume)
.addOnFailureListener { continuation.resumeWithException(it) }
.addOnCanceledListener { continuation.cancel() }
}
Changing await
to this workedlouiscad
06/03/2019, 7:56 AM