Skip to content

Commit e403331

Browse files
committed
fix: handle missing song data if the song is not found
1 parent e5594d7 commit e403331

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Prober/Lxns/Models/Record.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,30 @@ public Chart Chart
4040
{
4141
if (field is null)
4242
{
43-
Song song = SongData.Shared.Songs.First(x => x.Id == Id);
43+
Song? song = SongData.Shared.Songs.FirstOrDefault(x => x.Id == Id);
44+
if (song is null)
45+
{
46+
field = new()
47+
{
48+
Type = Type,
49+
Difficulty = Difficulty,
50+
Level = Level,
51+
LevelValue = 0.4,
52+
Charter = string.Empty,
53+
Version = 0,
54+
Notes = new()
55+
{
56+
Break = 0,
57+
Hold = 0,
58+
Slide = 0,
59+
Tap = 0,
60+
Total = 0,
61+
Touch = 0
62+
}
63+
};
64+
return field;
65+
}
66+
4467
field = (Type switch
4568
{
4669
SongTypes.Standard => song.Charts.Standard,

0 commit comments

Comments
 (0)