Refactor JSON handling in network requests
This commit is contained in:
parent
c8792d3ead
commit
a0e44307e0
|
|
@ -112,15 +112,19 @@ public class PlaywrightInstance : IDisposable
|
|||
e.Request.ResourceType == "fetch")
|
||||
{
|
||||
Serilog.Log.Information($"fetched: {e.Url}");
|
||||
JsonElement? json = null;
|
||||
try
|
||||
{
|
||||
var json = await e.JsonAsync();
|
||||
fetched(e.Url.ToLower(), JsonSerializer.Serialize(json));
|
||||
json = await e.JsonAsync();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
fetched(e.Url.ToLower(), JsonSerializer.Serialize(json ?? new JsonElement()));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue