Skip to content

Commit a7f82d2

Browse files
committed
chore: 初始化时的错误提示
1 parent ac0a258 commit a7f82d2

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

MaiChartManager/StaticSettings.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,29 @@ public partial class StaticSettings
1818
public StaticSettings(ILogger<StaticSettings> logger)
1919
{
2020
_logger = logger;
21-
if (string.IsNullOrEmpty(GamePath))
21+
22+
try
2223
{
23-
throw new ArgumentException("未指定游戏目录");
24-
}
24+
if (string.IsNullOrEmpty(GamePath))
25+
{
26+
throw new ArgumentException("未指定游戏目录");
27+
}
2528

26-
AssetDir = "A500";
27-
ScanMusicList();
28-
ScanGenre();
29-
ScanVersionList();
30-
ScanAssetBundles();
31-
ScanSoundData();
32-
GetGameVersion();
29+
AssetDir = "A500";
30+
GetGameVersion();
31+
ScanMusicList();
32+
ScanGenre();
33+
ScanVersionList();
34+
ScanAssetBundles();
35+
ScanSoundData();
36+
}
37+
catch (Exception e)
38+
{
39+
_logger.LogError(e, "初始化数据目录时出错");
40+
SentrySdk.CaptureException(e);
41+
MessageBox.Show(e.Message, "初始化数据目录时出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
42+
Application.Exit();
43+
}
3344
}
3445

3546
[GeneratedRegex(@"^\w\d{3}$")]
@@ -76,7 +87,7 @@ public void ScanMusicList()
7687
MusicList.Add(musicXml);
7788
}
7889

79-
_logger.LogInformation($"Scan music list, found {MusicList.Count} music.");
90+
_logger.LogInformation("Scan music list, found {0} music.", MusicList.Count);
8091
}
8192

8293
public void ScanGenre()
@@ -102,7 +113,7 @@ public void ScanGenre()
102113
}
103114
}
104115

105-
_logger.LogInformation($"Scan genre list, found {GenreList.Count} genre.");
116+
_logger.LogInformation("Scan genre list, found {0} genre.", GenreList.Count);
106117
}
107118

108119
public void ScanVersionList()

0 commit comments

Comments
 (0)