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 @@ -92,7 +92,7 @@ private inline fun <R> rethrow(function: () -> R): R {
92
92
}
93
93
}
94
94
95
- private fun errorToException (cause : dynamic ) = when (val code = ( cause.code as String? )?.toLowerCase()) {
95
+ private fun errorToException (cause : dynamic ) = when (val code = cause.code?.toString( )?.toLowerCase()) {
96
96
" auth/invalid-user-token" -> FirebaseAuthInvalidUserException (code, cause)
97
97
" auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException (code, cause)
98
98
" auth/user-disabled" -> FirebaseAuthInvalidUserException (code, cause)
@@ -106,7 +106,10 @@ private fun errorToException(cause: dynamic) = when(val code = (cause.code as St
106
106
// "auth/operation-not-allowed" ->
107
107
// "auth/too-many-arguments" ->
108
108
// "auth/unauthorized-domain" ->
109
- else -> FirebaseAuthException (code, cause)
109
+ else -> {
110
+ println (" Unknown error code in ${JSON .stringify(cause)} " )
111
+ FirebaseAuthException (code, cause)
112
+ }
110
113
}
111
114
112
115
actual object EmailAuthProvider {
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