Skip to content

Commit 06f3ada

Browse files
authored
Merge branch 'master' into increase_auth_coverage
2 parents 295b2a7 + 7552695 commit 06f3ada

File tree

2 files changed

+11
-5
lines changed
  • firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth
  • firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore

2 files changed

+11
-5
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ internal inline fun <R> rethrow(function: () -> R): R {
127127
}
128128
}
129129

130-
private fun errorToException(cause: dynamic) = when(val code = (cause.code as String?)?.toLowerCase()) {
130+
private fun errorToException(cause: dynamic) = when(val code = cause.code?.toString()?.toLowerCase()) {
131131
"auth/invalid-user-token" -> FirebaseAuthInvalidUserException(code, cause)
132132
"auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException(code, cause)
133133
"auth/user-disabled" -> FirebaseAuthInvalidUserException(code, cause)
@@ -151,5 +151,8 @@ private fun errorToException(cause: dynamic) = when(val code = (cause.code as St
151151
// "auth/operation-not-allowed" ->
152152
// "auth/too-many-arguments" ->
153153
// "auth/unauthorized-domain" ->
154-
else -> FirebaseAuthException(code, cause)
154+
else -> {
155+
println("Unknown error code in ${JSON.stringify(cause)}")
156+
FirebaseAuthException(code, cause)
157+
}
155158
}

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ inline fun <R> rethrow(function: () -> R): R {
392392
}
393393
}
394394

395-
fun errorToException(e: dynamic) = when(e?.code?.toLowerCase()) {
395+
fun errorToException(e: dynamic) = when(e?.code?.toString()?.toLowerCase()) {
396396
"cancelled" -> FirebaseFirestoreException(e, FirestoreExceptionCode.CANCELLED)
397397
"invalid-argument" -> FirebaseFirestoreException(e, FirestoreExceptionCode.INVALID_ARGUMENT)
398398
"deadline-exceeded" -> FirebaseFirestoreException(e, FirestoreExceptionCode.DEADLINE_EXCEEDED)
@@ -408,6 +408,9 @@ fun errorToException(e: dynamic) = when(e?.code?.toLowerCase()) {
408408
"unavailable" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAVAILABLE)
409409
"data-loss" -> FirebaseFirestoreException(e, FirestoreExceptionCode.DATA_LOSS)
410410
"unauthenticated" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNAUTHENTICATED)
411-
// "unknown" ->
412-
else -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
411+
"unknown" -> FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
412+
else -> {
413+
println("Unknown error code in ${JSON.stringify(e)}")
414+
FirebaseFirestoreException(e, FirestoreExceptionCode.UNKNOWN)
415+
}
413416
}

0 commit comments

Comments
 (0)