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")
|
e.Request.ResourceType == "fetch")
|
||||||
{
|
{
|
||||||
Serilog.Log.Information($"fetched: {e.Url}");
|
Serilog.Log.Information($"fetched: {e.Url}");
|
||||||
|
JsonElement? json = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var json = await e.JsonAsync();
|
json = await e.JsonAsync();
|
||||||
fetched(e.Url.ToLower(), JsonSerializer.Serialize(json));
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Serilog.Log.Error(ex.ToString());
|
Serilog.Log.Error(ex.ToString());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
fetched(e.Url.ToLower(), JsonSerializer.Serialize(json ?? new JsonElement()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue