Sometimes, while flushing the session and event cache, a serialisation error can occur.
This PR improves the handling of those errors. The new setup is as follows:
if an error occurs while trying to serialise the json into a dictionary then we silently remove the offending file, as it is most likely caused by an unpreventable IO error.
if an error occurs while trying to create an event or session from the dictionary then we remove the file. At a later date we will implement reporting this issue internally.
File writing
It could be possible the the method File.writeAllText is buffered under the hood. So we are now using a file stream to write data and using the method FileStream.Flush to force it to write all at once.
Goal
Error handling
Sometimes, while flushing the session and event cache, a serialisation error can occur.
This PR improves the handling of those errors. The new setup is as follows:
File writing
It could be possible the the method File.writeAllText is buffered under the hood. So we are now using a file stream to write data and using the method FileStream.Flush to force it to write all at once.
Testing
Covered by existing tests