2014-06-27 24 views
0

我正在使用Unity Parse SDK作爲登錄系統。一切工作正常,如果登錄信息是正確的,如果它不正確,那麼它會導致異常,導致與我的Prime31 Etcetera警報彈出衝突。該例外似乎不會導致任何其他問題,否則應用程序運行良好。Unity解析SDK登錄失敗異常404

例外:

System.AggregateException: Exception of type 'System.AggregateException' was thrown. 

----------------- 

Parse.ParseException: 404: not found 

    at Parse.ParseClient+<>c__DisplayClass8.<RequestAsync>b__7 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0 

    at Parse.Internal.InternalExtensions+<>c__DisplayClass1`2[System.Tuple`2[System.Net.HttpStatusCode,System.String],System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__0 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 

    at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0 

    at System.Threading.Tasks.Task+<>c__DisplayClass3`1+<>c__DisplayClass5[System.Threading.Tasks.Task`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]]].<ContinueWith>b__2() [0x00000] in <filename unknown>:0 

我試圖抓住使用

catch(System.AggregateException e) 

catch(System.Exception e) 

的異常,但既不似乎抓住它。

我有一個臨時解決方案,通過延遲一幀的激活來使用Etcetera。然而,這不是一個完美的解決方案,有可能一個幀偏移仍然會失敗。

我該如何正確捕捉這個異常或以其他方式處理/避免它?

謝謝

回答

0

,而不是試圖捕獲異常,檢查任務發生故障:

Task t = ParseUser.LogInAsync(username, password); 
while (!t.IsCompleted) 
    yield return null; 

if (t.IsCanceled || t.IsFaulted) 
{ 
    // the exception can be found in t.Exception 
} 
else 
{ 
    // login successful 
} 

至於獲取有關當前404異常的更多信息,你是不幸的運氣。 Parse在Unity中沒有提供更多信息,顯然是由於Unity的HTTP棧有限。更多的信息在這裏:https://www.parse.com/questions/unity-sdk-handling-errors

相關問題