facebook twitter hatena line email

Unity/Csharp/Exception

提供: 初心者エンジニアの簡易メモ
2023年10月3日 (火) 23:31時点におけるAdmin (トーク | 投稿記録)による版

移動: 案内検索

Exception例文

void Exec()
{
    try
    {
        Hoge();
    }
    catch (Exception e)
    {
        Debug.LogError(e.Message + ": [" + e.StackTrace + "] name:" + e.GetType().Name);
        Debug.LogError(e.Message + " " + e);
    }
}
void Hoge()
{
    throw new Exception("例外エラーNormal");
}

出力(e.StatkcTrace)

at ExceptionScene.HogeAsync () [0x00074] in Assets/Scripts/Scene/ExceptionScene.cs:43 
  at Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1[TStateMachine].GetResult (System.Int16 token) [0x00000] in ./Library/PackageCache/com.cysharp.unitask@b992a061fb/Runtime/CompilerServices/StateMachineRunner.cs:218 
  at ExceptionScene.Exec () [0x00023] in /Assets/Scripts/Scene/ExceptionScene.cs:26

出力(e.Message)

例外エラーNormal

出力(e.GetType().Name)

Exception

出力(e)

System.Exception: 例外エラーAsync
  at ExceptionScene.HogeAsync () [0x00074] in Assets/Scripts/Scene/ExceptionScene.cs:43 
  at Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1[TStateMachine].GetResult (System.Int16 token) [0x00000] in ./Library/PackageCache/com.cysharp.unitask@b992a061fb/Runtime/CompilerServices/StateMachineRunner.cs:218 
  at ExceptionScene.Exec () [0x00023] in Assets/Scripts/Scene/ExceptionScene.cs:26

関連

Unity/クラッシュ [ショートカット]