Skip to content

Commit

Permalink
Fixed issue, better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Sep 23, 2024
1 parent c3669a9 commit dbd8e7e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using Microsoft.Extensions.Logging;

namespace BUTR.Site.NexusMods.Server.CrashReport.v13;

Expand All @@ -35,6 +36,7 @@ private static string GetException(ExceptionModel? exception, bool inner = false
""";

public static bool TryFromJson(
ILogger logger,
IUnitOfWrite unitOfWrite,
TenantId tenant,
CrashReportFileId fileId,
Expand All @@ -59,8 +61,9 @@ public static bool TryFromJson(
{
report = JsonSerializer.Deserialize<CrashReportModel>(content);
}
catch
catch (Exception e)
{
logger.LogError(e, "Failed to parse JSON crash report. FileId: {FileId}, Url: {Url}", fileId, url);
report = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BUTR.CrashReport.Models" Version="14.0.0.84" />
<PackageReference Include="BUTR.CrashReport.Bannerlord.Parser" Version="14.0.0.84" />
<PackageReference Include="BUTR.CrashReport.Models" Version="14.0.0.85" />
<PackageReference Include="BUTR.CrashReport.Bannerlord.Parser" Version="14.0.0.85" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.Json;
using Microsoft.Extensions.Logging;

namespace BUTR.Site.NexusMods.Server.CrashReport.v14;

Expand All @@ -36,6 +37,7 @@ private static string GetException(ExceptionModel? exception, bool inner = false
""";

public static bool TryFromHtml(
ILogger logger,
IUnitOfWrite unitOfWrite,
TenantId tenant,
CrashReportFileId fileId,
Expand All @@ -52,8 +54,9 @@ public static bool TryFromHtml(
{
report = CrashReportParser.ParseLegacyHtml(version, content);
}
catch
catch (Exception e)
{
logger.LogError(e, "Failed to parse HTML crash report. FileId: {FileId}, Url: {Url}", fileId, url);
report = null;
}

Expand All @@ -69,6 +72,7 @@ public static bool TryFromHtml(
}

public static bool TryFromJson(
ILogger logger,
IUnitOfWrite unitOfWrite,
TenantId tenant,
CrashReportFileId fileId,
Expand All @@ -93,8 +97,9 @@ public static bool TryFromJson(
{
report = JsonSerializer.Deserialize<CrashReportModel>(content);
}
catch
catch (Exception e)
{
logger.LogError(e, "Failed to parse JSON crash report. FileId: {FileId}, Url: {Url}", fileId, url);
report = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private async Task<int> WriteCrashReportsToDatabaseAsync(CancellationToken ct)
if (version <= 12)
{
var result = CrashReportV14.TryFromHtml(
_logger,
unitOfWrite,
tenant,
fileId,
Expand All @@ -240,6 +241,7 @@ private async Task<int> WriteCrashReportsToDatabaseAsync(CancellationToken ct)
if (version == 13)
{
var result = CrashReportV13.TryFromJson(
_logger,
unitOfWrite,
tenant,
fileId,
Expand All @@ -259,6 +261,7 @@ private async Task<int> WriteCrashReportsToDatabaseAsync(CancellationToken ct)
if (version == 14)
{
var result = CrashReportV14.TryFromJson(
_logger,
unitOfWrite,
tenant,
fileId,
Expand Down

0 comments on commit dbd8e7e

Please sign in to comment.