facebook twitter hatena line email

「Unity/Csharp/Exception」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(内容を「Unity/Csharp/Exception/Exception」で置換)
行1: 行1:
==Exception例文==
+
[[Unity/Csharp/Exception/Exception]]
<pre>
+
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");
+
}
+
</pre>
+
 
+
出力(e.StatkcTrace)
+
<pre>
+
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
+
</pre>
+
 
+
出力(e.Message)
+
例外エラーNormal
+
 
+
出力(e.GetType().Name)
+
Exception
+
 
+
出力(e)
+
<pre>
+
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
+
</pre>
+
 
+
==関連==
+
[[Unity/クラッシュ]] [ショートカット]
+

2023年10月17日 (火) 15:40時点における版

Unity/Csharp/Exception/Exception