2017-02-16 67 views
0

美好的一天!統一的firebase捕獲異常錯誤

我們正在與Firebase一起使用Unity。我們提到了統一的Firebase指南。我們嘗試從不存在的存儲中下載文件,並返回超出重試限制的錯誤。我們希望捕獲此錯誤並顯示我們自定義的錯誤消息,因爲重試限制超出的默認例外時間很長。以下是我們用於打印異常的代碼示例。

imaginary_ref.GetBytesAsync (maxAllowedSize).ContinueWith (task => { 
     if (task.IsFaulted || task.IsCanceled) { 
      Debug.Log (task.Exception.ToString()); 
     } 
     else if (task.IsCompleted) { 
      Debug.Log ("Successful download!"); 
     } else{ 
      Debug.Log (task.Exception.ToString()); 
     } 
    }); 

在上面的例子中,我們想捕獲任務異常並打印自己的錯誤,但沒有相關文檔。

Ex。

if (ErrorRetryLimitExceeded) 
Debug.Log("Retry Limit Exceeded"); 
else if (ErrorCanceled) 
Debug.Log("Download was canceled by user"); 

firebase現在還有Firebase Authorization for Unity的異常參考嗎?

謝謝!

回答

0

Firebase開發人員在這裏。

是的,這應該可以通過使用StorageException.ErrorCode的Firebase存儲來實現。

imaginary_ref.GetBytesAsync (maxAllowedSize).ContinueWith (task => { 
    if (task.IsFaulted || task.IsCanceled) { 
     AggregateException ex = task.Exception as AggregateException; 
     if (ex != null) { 
      StorageException inner = ex.InnerExceptions[0] as StorageException; 
      if (inner != null && inner.ErrorCode == StorageException.ErrorRetryLimitExceeded) { 
      Debug.Log ("retry failed!"); 
      } 
     } 
    } 
    else if (task.IsCompleted) { 
     Debug.Log ("Successful download!"); 
    } 
}); 
+1

謝謝,這幫了我很多。我注意到我無法爲FirebaseAuth做到這一點? –

+1

FirebaseAuth有類似的東西嗎?這將是非常有用的 –