「Unity/sentry」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→async内でexceptionを出す場合) |
|||
| 行119: | 行119: | ||
async UniTask<float> ExecUniTask() | async UniTask<float> ExecUniTask() | ||
{ | { | ||
| + | await UniTask.Delay(1000); | ||
throw new Exception("例外エラー1"); | throw new Exception("例外エラー1"); | ||
return 100f; | return 100f; | ||
2023年8月11日 (金) 02:58時点における版
目次
Sentryとは
バグのエラーログなどをクラウド上で確認できるサービス
インストール
PackageManagerのgit urlから以下を設定
https://github.com/getsentry/unity.git#1.5.0
sentryのweb管理画面に表示されてるDNSのURLを、Unityメインメニュー/tools/sentryに入れる。
プラン
無料
- トラッキング件数/月:5000件
- ユーザー数:1人
- ログ保持期間:30日間
チーム(26$/月)
- トラッキング件数/月:10万件
- ユーザー数:無制限
- ログ保持期間:90日間
ビジネス(80$/月)
- トラッキング件数/月:10万件
- ユーザー数:無制限
- ログ保持期間:90日間
色々なログ
Exceptionをそのままthrow
void Start()
{
Exec();
}
void Exec()
{
throw new Exception("例外エラー1");
}
ログ
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
try-catchをせず、アプリに対してthrow Exceptionしてしまう。
Exceptionをtry-catchで取得したとき
try
{
Exec();
}
catch (Exception e)
{
Debug.LogError(e.Message + ":" + e.StackTrace);
}
ログ
例外エラー1: at ExceptionScene.Exec () [0x00000] in HogeProject/Assets/Scripts/ExceptionScene.cs:26 at ExceptionScene.Start () [0x0000a] in HogeProjectAssets/Scripts/ExceptionScene.cs:15
async内でexceptionを出す場合
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;
}
ログ
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
ExceptionがStart側まで戻れず、try-catchができず、アプリに対して、Exceptionをthrowしてしまう。
async内でexceptionを出し、async内でtry-catch
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;
}
ログ
例外エラー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
try-catchできる。
