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 Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ internal inline fun <R> rethrow(function: () -> R): R {
127
127
}
128
128
}
129
129
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()) {
131
131
" auth/invalid-user-token" -> FirebaseAuthInvalidUserException (code, cause)
132
132
" auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException (code, cause)
133
133
" auth/user-disabled" -> FirebaseAuthInvalidUserException (code, cause)
@@ -151,5 +151,8 @@ private fun errorToException(cause: dynamic) = when(val code = (cause.code as St
151
151
// "auth/operation-not-allowed" ->
152
152
// "auth/too-many-arguments" ->
153
153
// "auth/unauthorized-domain" ->
154
- else -> FirebaseAuthException (code, cause)
154
+ else -> {
155
+ println (" Unknown error code in ${JSON .stringify(cause)} " )
156
+ FirebaseAuthException (code, cause)
157
+ }
155
158
}
Original file line number Diff line number Diff line change @@ -392,7 +392,7 @@ inline fun <R> rethrow(function: () -> R): R {
392
392
}
393
393
}
394
394
395
- fun errorToException (e : dynamic ) = when (e?.code?.toLowerCase()) {
395
+ fun errorToException (e : dynamic ) = when (e?.code?.toString()?. toLowerCase()) {
396
396
" cancelled" -> FirebaseFirestoreException (e, FirestoreExceptionCode .CANCELLED )
397
397
" invalid-argument" -> FirebaseFirestoreException (e, FirestoreExceptionCode .INVALID_ARGUMENT )
398
398
" deadline-exceeded" -> FirebaseFirestoreException (e, FirestoreExceptionCode .DEADLINE_EXCEEDED )
@@ -408,6 +408,9 @@ fun errorToException(e: dynamic) = when(e?.code?.toLowerCase()) {
408
408
" unavailable" -> FirebaseFirestoreException (e, FirestoreExceptionCode .UNAVAILABLE )
409
409
" data-loss" -> FirebaseFirestoreException (e, FirestoreExceptionCode .DATA_LOSS )
410
410
" 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
+ }
413
416
}
You can’t perform that action at this time.
0 commit comments