File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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 {
9292 }
9393}
9494
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()) {
9696 " auth/invalid-user-token" -> FirebaseAuthInvalidUserException (code, cause)
9797 " auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException (code, cause)
9898 " auth/user-disabled" -> FirebaseAuthInvalidUserException (code, cause)
@@ -106,7 +106,10 @@ private fun errorToException(cause: dynamic) = when(val code = (cause.code as St
106106// "auth/operation-not-allowed" ->
107107// "auth/too-many-arguments" ->
108108// "auth/unauthorized-domain" ->
109- else -> FirebaseAuthException (code, cause)
109+ else -> {
110+ println (" Unknown error code in ${JSON .stringify(cause)} " )
111+ FirebaseAuthException (code, cause)
112+ }
110113}
111114
112115actual object EmailAuthProvider {
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments