Skip to content

Commit 8aed2b3

Browse files
authored
Merge pull request #169 from GitLiveApp/GL-370-could-not-resolve-host--github-com
Added fix for bug in firebase.js, due to exception missing code.
2 parents 7122b86 + c6c0ef9 commit 8aed2b3

File tree

1 file changed

+26
-21
lines changed
  • firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore

1 file changed

+26
-21
lines changed

firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -471,25 +471,30 @@ inline fun <R> rethrow(function: () -> R): R {
471471
}
472472
}
473473

474-
fun errorToException(e: dynamic) = when(e?.code?.toString()?.toLowerCase()) {
475-
"cancelled" -> FirebaseFirestoreException(e, FirestoreExceptionCode.CANCELLED)
476-
"invalid-argument" -> FirebaseFirestoreException(e, FirestoreExceptionCode.INVALID_ARGUMENT)
477-
"deadline-exceeded" -> FirebaseFirestoreException(e, FirestoreExceptionCode.DEADLINE_EXCEEDED)
478-
"not-found" -> FirebaseFirestoreException(e, FirestoreExceptionCode.NOT_FOUND)
479-
"already-exists" -> FirebaseFirestoreException(e, FirestoreExceptionCode.ALREADY_EXISTS)
480-
"permission-denied" -> FirebaseFirestoreException(e, FirestoreExceptionCode.PERMISSION_DENIED)
481-
"resource-exhausted" -> FirebaseFirestoreException(e, FirestoreExceptionCode.RESOURCE_EXHAUSTED)
482-
"failed-precondition" -> FirebaseFirestoreException(e, FirestoreExceptionCode.FAILED_PRECONDITION)
483-
"aborted" -> FirebaseFirestoreException(e, FirestoreExceptionCode.ABORTED)
484-
"out-of-range" -> FirebaseFirestoreException(e, FirestoreExceptionCode.OUT_OF_RANGE)
485-
"unimplemented" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNIMPLEMENTED)
486-
"internal" -> FirebaseFirestoreException(e, FirestoreExceptionCode.INTERNAL)
487-
"unavailable" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAVAILABLE)
488-
"data-loss" -> FirebaseFirestoreException(e, FirestoreExceptionCode.DATA_LOSS)
489-
"unauthenticated" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAUTHENTICATED)
490-
"unknown" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
491-
else -> {
492-
println("Unknown error code in ${JSON.stringify(e)}")
493-
FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
494-
}
474+
fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "")
475+
.toString()
476+
.toLowerCase()
477+
.let {
478+
when {
479+
"cancelled" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.CANCELLED)
480+
"invalid-argument" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.INVALID_ARGUMENT)
481+
"deadline-exceeded" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.DEADLINE_EXCEEDED)
482+
"not-found" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.NOT_FOUND)
483+
"already-exists" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.ALREADY_EXISTS)
484+
"permission-denied" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.PERMISSION_DENIED)
485+
"resource-exhausted" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.RESOURCE_EXHAUSTED)
486+
"failed-precondition" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.FAILED_PRECONDITION)
487+
"aborted" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.ABORTED)
488+
"out-of-range" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.OUT_OF_RANGE)
489+
"unimplemented" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNIMPLEMENTED)
490+
"internal" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.INTERNAL)
491+
"unavailable" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAVAILABLE)
492+
"data-loss" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.DATA_LOSS)
493+
"unauthenticated" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAUTHENTICATED)
494+
"unknown" in it -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
495+
else -> {
496+
println("Unknown error code in ${JSON.stringify(e)}")
497+
FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
498+
}
499+
}
495500
}

0 commit comments

Comments
 (0)