|
|
行2: |
行2: |
| | | |
| [[Unity/sentry/ログ]] | | [[Unity/sentry/ログ]] |
− |
| |
− | ==色々なログ==
| |
− | ===Exceptionをそのままthrow===
| |
− | <pre>
| |
− | void Start()
| |
− | {
| |
− | Exec();
| |
− | }
| |
− | void Exec()
| |
− | {
| |
− | throw new Exception("例外エラー1");
| |
− | }
| |
− | </pre>
| |
− | ログ
| |
− | <pre>
| |
− | Stack Trace
| |
− | System.Exception
| |
− | 例外エラー1
| |
− | HogeProject/Assets/Scripts/ExceptionScene.cs in Exec at line 26:9
| |
− | In App
| |
− | HogeProject/Assets/Scripts/ExceptionScene.cs in Start at line 15:13
| |
− | </pre>
| |
− |
| |
− | try-catchをせず、アプリに対してthrow Exceptionしてしまう。
| |
− |
| |
− | ===Exceptionをtry-catchで取得したとき===
| |
− | <pre>
| |
− | try
| |
− | {
| |
− | Exec();
| |
− | }
| |
− | catch (Exception e)
| |
− | {
| |
− | Debug.LogError(e.Message + ":" + e.StackTrace);
| |
− | }
| |
− | </pre>
| |
− | ログ
| |
− | <pre>
| |
− | 例外エラー1: at ExceptionScene.Exec () [0x00000] in HogeProject/Assets/Scripts/ExceptionScene.cs:26
| |
− | at ExceptionScene.Start () [0x0000a] in HogeProjectAssets/Scripts/ExceptionScene.cs:15
| |
− | </pre>
| |
− |
| |
− | ===async内でexceptionを出す場合===
| |
− | <pre>
| |
− | void Start()
| |
− | {
| |
− | try
| |
− | {
| |
− | Exec();
| |
− | }
| |
− | catch (Exception e)
| |
− | {
| |
− | Debug.LogError(e.Message + ":" + e.StackTrace);
| |
− | }
| |
− | }
| |
− | async void Exec()
| |
− | {
| |
− | var result = await ExecUniTask();
| |
− | Debug.Log("Exec " + result);
| |
− | }
| |
− | async UniTask<float> ExecUniTask()
| |
− | {
| |
− | await UniTask.Delay(1000);
| |
− | throw new Exception("例外エラー1");
| |
− | return 100f;
| |
− | }
| |
− | </pre>
| |
− | ログ
| |
− | <pre>
| |
− | HogeProject/Assets/Scripts/ExceptionScene.cs in ExecUniTask at line 32:9
| |
− | In App
| |
− | Hoge/Library/PackageCache/com.cysharp.unitask@b992a061fb/Runtime/UniTask.Factory.cs in GetResult at line 255:17
| |
− | In App
| |
− | HogeProject/Assets/Scripts/ExceptionScene.cs in Exec at line 26:9
| |
− | In App
| |
− | </pre>
| |
− | ExceptionがStart側まで戻れず、try-catchができず、アプリに対して、Exceptionをthrowしてしまう。
| |
− |
| |
− | ===async内でexceptionを出し、async内でtry-catch===
| |
− | <pre>
| |
− | void Start()
| |
− | {
| |
− | Exec();
| |
− | }
| |
− | async void Exec()
| |
− | {
| |
− | try
| |
− | {
| |
− | var result = await ExecUniTask();
| |
− | Debug.Log("Exec " + result);
| |
− | }
| |
− | catch (Exception e)
| |
− | {
| |
− | Debug.LogError(e.Message + ":" + e.StackTrace);
| |
− | }
| |
− | }
| |
− | async UniTask<float> ExecUniTask()
| |
− | {
| |
− | await UniTask.Delay(1000);
| |
− | throw new Exception("例外エラー1");
| |
− | return 100f;
| |
− | }
| |
− | </pre>
| |
− |
| |
− | ログ
| |
− | <pre>
| |
− | 例外エラー1: at ExceptionScene.ExecUniTask () [0x00000] in HogeProject/Assets/Scripts/ExceptionScene.cs:31
| |
− | at Cysharp.Threading.Tasks.UniTask+ExceptionResultSource`1[T].GetResult (System.Int16 token) [0x00015] in HogeLibrary/PackageCache/com.cysharp.unitask@b992a061fb/Runtime/UniTask.Factory.cs:255
| |
− | at ExceptionScene.Exec () [0x00024] in HogeProject/Assets/Scripts/ExceptionScene.cs:19
| |
− | </pre>
| |
− | try-catchできる。
| |