not call fetched if exception errors.

This commit is contained in:
Haiping Chen 2024-07-17 07:05:16 -05:00
parent c81e2ed3d6
commit 9eeef70874

View file

@ -115,16 +115,20 @@ public class PlaywrightInstance : IDisposable
JsonElement? json = null;
try
{
json = await e.JsonAsync();
if (e.Status == 200 && e.Ok)
{
json = await e.JsonAsync();
}
else
{
Serilog.Log.Warning($"Response status: {e.Status} {e.StatusText}, OK: {e.Ok}");
}
fetched(e.Url.ToLower(), JsonSerializer.Serialize(json));
}
catch(Exception ex)
{
Serilog.Log.Error(ex.ToString());
}
finally
{
fetched(e.Url.ToLower(), JsonSerializer.Serialize(json ?? new JsonElement()));
}
}
};
}