我试图退出Firebase API,但似乎无法弄清楚如何处理可能发生的任何错误。在Swift中退出Firebase
的火力地堡吊舱提供用于登出的方法:
FIRAuth.auth()?.signOut()
它标有throws
,所以我在do
/try
/catch
块在测试签名出过程的方法包裹它:
do {
try FIRAuth.auth()?.signOut()
} catch (let error) {
print((error as NSError).code)
}
我看到signOut
方法标记在火力地堡荚throws
,但我看不出它如何处理异步的任何错误LY。我尝试了进入飞行模式,这触发了网络请求发生时我的代码中的网络错误,但是使用signOut
方法时,未捕获该错误,因为我没有可执行的完成处理程序。 Firebase窗格中的所有其他身份验证方法都有一个完成处理程序,我可以在其中处理错误。
下面是从火力地堡吊舱signOut
方法的文档:
/** @fn signOut:
@brief Signs out the current user.
@param error Optionally; if an error occurs, upon return contains an NSError object that
describes the problem; is nil otherwise.
@return @YES when the sign out request was successful. @NO otherwise.
@remarks Possible error codes:
- @c FIRAuthErrorCodeKeychainError Indicates an error occurred when accessing the keychain.
The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary
will contain more information about the error encountered.
*/
open func signOut() throws
你有一个适当的方法来处理签约了用户的任何建议时,我没有完成处理程序允许我检查错误?