我試圖退出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
你有一個適當的方法來處理簽約了用戶的任何建議時,我沒有完成處理程序允許我檢查錯誤?