@@ -160,16 +160,17 @@ internal fun ActionCodeSettings.toIos() = FIRActionCodeSettings().also {
160160 iOSBundleId?.run { it.setIOSBundleID(this ) }
161161}
162162
163- public actual open class FirebaseAuthException (message : String ) : FirebaseException(message)
164- public actual open class FirebaseAuthActionCodeException (message : String ) : FirebaseAuthException(message)
165- public actual open class FirebaseAuthEmailException (message : String ) : FirebaseAuthException(message)
166- public actual open class FirebaseAuthInvalidCredentialsException (message : String ) : FirebaseAuthException(message)
167- public actual open class FirebaseAuthWeakPasswordException (message : String ) : FirebaseAuthInvalidCredentialsException(message)
168- public actual open class FirebaseAuthInvalidUserException (message : String ) : FirebaseAuthException(message)
169- public actual open class FirebaseAuthMultiFactorException (message : String , public val resolver : FIRMultiFactorResolver ? ) : FirebaseAuthException(message)
170- public actual open class FirebaseAuthRecentLoginRequiredException (message : String ) : FirebaseAuthException(message)
171- public actual open class FirebaseAuthUserCollisionException (message : String ) : FirebaseAuthException(message)
172- public actual open class FirebaseAuthWebException (message : String ) : FirebaseAuthException(message)
163+ public actual open class FirebaseAuthException (message : String , internal val authCode : String? = null ) : FirebaseException(message)
164+ public actual val FirebaseAuthException .code: String? get() = authCode
165+ public actual open class FirebaseAuthActionCodeException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
166+ public actual open class FirebaseAuthEmailException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
167+ public actual open class FirebaseAuthInvalidCredentialsException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
168+ public actual open class FirebaseAuthWeakPasswordException (message : String , code : String? = null ) : FirebaseAuthInvalidCredentialsException(message, code)
169+ public actual open class FirebaseAuthInvalidUserException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
170+ public actual open class FirebaseAuthMultiFactorException (message : String , public val resolver : FIRMultiFactorResolver ? , code : String? = null ) : FirebaseAuthException(message, code)
171+ public actual open class FirebaseAuthRecentLoginRequiredException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
172+ public actual open class FirebaseAuthUserCollisionException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
173+ public actual open class FirebaseAuthWebException (message : String , code : String? = null ) : FirebaseAuthException(message, code)
173174
174175internal fun <T , R > T.throwError (block : T .(errorPointer: CPointer <ObjCObjectVar <NSError ?>>) -> R ): R {
175176 memScoped {
@@ -214,10 +215,10 @@ private fun NSError.toException() = when (domain) {
214215 FIRAuthErrorDomain -> when (code) {
215216 17030L , // AuthErrorCode.invalidActionCode
216217 17029L , // AuthErrorCode.expiredActionCode
217- -> FirebaseAuthActionCodeException (toString())
218+ -> FirebaseAuthActionCodeException (toString(), code.toString() )
218219
219220 17008L , // AuthErrorCode.invalidEmail
220- -> FirebaseAuthEmailException (toString())
221+ -> FirebaseAuthEmailException (toString(), code.toString() )
221222
222223 17056L , // AuthErrorCode.captchaCheckFailed
223224 17042L , // AuthErrorCode.invalidPhoneNumber
@@ -228,24 +229,25 @@ private fun NSError.toException() = when (domain) {
228229 17043L , // AuthErrorCode.missingVerificationCode
229230 17021L , // AuthErrorCode.userTokenExpired
230231 17004L , // AuthErrorCode.invalidCredential
231- -> FirebaseAuthInvalidCredentialsException (toString())
232+ 17009L , // AuthErrorCode.wrongPassword
233+ -> FirebaseAuthInvalidCredentialsException (toString(), code.toString())
232234
233235 17026L , // AuthErrorCode.weakPassword
234- -> FirebaseAuthWeakPasswordException (toString())
236+ -> FirebaseAuthWeakPasswordException (toString(), code.toString() )
235237
236238 17017L , // AuthErrorCode.invalidUserToken
237- -> FirebaseAuthInvalidUserException (toString())
239+ -> FirebaseAuthInvalidUserException (toString(), code.toString() )
238240
239241 17014L , // AuthErrorCode.requiresRecentLogin
240- -> FirebaseAuthRecentLoginRequiredException (toString())
242+ -> FirebaseAuthRecentLoginRequiredException (toString(), code.toString() )
241243
242244 17087L , // AuthErrorCode.secondFactorAlreadyEnrolled
243245 17078L , // AuthErrorCode.secondFactorRequired
244246 17088L , // AuthErrorCode.maximumSecondFactorCountExceeded
245247 17084L , // AuthErrorCode.multiFactorInfoNotFound
246248 -> {
247249 val resolver = userInfo[" FIRAuthErrorUserInfoMultiFactorResolverKey" ] as ? FIRMultiFactorResolver
248- FirebaseAuthMultiFactorException (toString(), resolver)
250+ FirebaseAuthMultiFactorException (toString(), resolver, code.toString() )
249251 }
250252
251253 17052L , // AuthErrorCode.quotaExceeded
@@ -254,17 +256,17 @@ private fun NSError.toException() = when (domain) {
254256 17007L , // AuthErrorCode.emailAlreadyInUse
255257 17012L , // AuthErrorCode.accountExistsWithDifferentCredential
256258 17025L , // AuthErrorCode.credentialAlreadyInUse
257- -> FirebaseAuthUserCollisionException (toString())
259+ -> FirebaseAuthUserCollisionException (toString(), code.toString() )
258260
259261 17057L , // AuthErrorCode.webContextAlreadyPresented
260262 17058L , // AuthErrorCode.webContextCancelled
261263 17062L , // AuthErrorCode.webInternalError
262- -> FirebaseAuthWebException (toString())
264+ -> FirebaseAuthWebException (toString(), code.toString() )
263265
264266 17020L , // AuthErrorCode.networkError
265267 -> FirebaseNetworkException (toString())
266268
267- else -> FirebaseAuthException (toString())
269+ else -> FirebaseAuthException (toString(), code.toString() )
268270 }
269271 else -> FirebaseAuthException (toString())
270272}
0 commit comments