Skip to content

Commit

Permalink
Improved: Log unknown issues as errors instead of killing reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Nov 18, 2024
1 parent 3f9d245 commit 807131d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async IAsyncEnumerable<Diagnostic> Diagnose(Loadout.ReadOnly loadout, Can
}
}

private static Diagnostic? CreateDiagnostic(ModuleIssueV2 issue)
private Diagnostic? CreateDiagnostic(ModuleIssueV2 issue)
{
return issue switch
{
Expand Down Expand Up @@ -194,7 +194,15 @@ public async IAsyncEnumerable<Diagnostic> Diagnose(Loadout.ReadOnly loadout, Can
ModuleVersionMismatchIssue moduleVersionMismatchIssue => null,

// A new variant that's unknown to our code.
_ => throw new ArgumentOutOfRangeException(nameof(issue), issue, null),
_ => LogAndReturnUnknownDiagnostic(issue),
};
}

private Diagnostic? LogAndReturnUnknownDiagnostic(ModuleIssueV2 issue)
{
_logger.LogError("Unknown issue. This indicates an update in `Bannerlord.ModuleManager`" +
"which is not handled on our end in a switch statement.\n" +
"Issue text is below: {Issue}", issue);
return null;
}
}

0 comments on commit 807131d

Please sign in to comment.