Skip to content

Commit

Permalink
Log deserialization errors in MockApmServer
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Dec 5, 2024
1 parent 51fbbea commit 33bf3c5
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,18 @@ private async Task<int> ParsePayload()
private async Task ParsePayloadLineAndAddToReceivedData(string line)
{
var foundDto = false;
var payload = JsonSerializer
.Deserialize<PayloadLineDto>(line, JsonSerializerOptions) ?? throw new ArgumentException("Deserialization failed");

PayloadLineDto payload;
try
{
payload = JsonSerializer.Deserialize<PayloadLineDto>(line, JsonSerializerOptions)
?? throw new ArgumentException("Deserialization failed");
}
catch (JsonException ex)
{
_logger?.Error()?.LogException(ex, "Failed to deserialize '{Line}'", line);
throw;
}

await HandleParsed(nameof(payload.Error), payload.Error, _mockApmServer.ReceivedData.Errors, _mockApmServer.AddError);
await HandleParsed(nameof(payload.Metadata), payload.Metadata, _mockApmServer.ReceivedData.Metadata, _mockApmServer.AddMetadata);
Expand Down

0 comments on commit 33bf3c5

Please sign in to comment.