IntelliTect / TestTools

A collection of tools for aiding in test automation
MIT License
10 stars 7 forks source link

Change try/catch around JSON serialization to a general Exception catch #106

Closed PandaMagnus closed 3 years ago

PandaMagnus commented 3 years ago

Long story short, I found some different behavior in how System.Text.Json's JsonSerializer.Serialize works. In one specific scenario (attempting to serialize an object results in a property on said object throwing an exception) I saw two different behaviors: 1) Throw a TargetInvocationException with an inner exception of whatever the object threw 2) Throw the original exception (in this case, it happened to be a Selenium WebDriverException)

To prevent having to explicitly catch just all of the exceptions, the code change is to catch a regular ol' Exception in this one specific case, because we don't want logging to behave different and risk stopping a test because some property couldn't be evaluated at log-time.