We need to standardize on the custom exceptions that we throw and allow the DocServer to emit actionable error messages to the user if possible.
Solution
This PR adapts our existing PersistenceException to require an ErrorCode and allows it to be used in more general scenarios.
We also shore up the APIs for serializing/deserializing yaml and json to wrap exceptions coming from the serialization libraries.
Changes
Added required ErrorCode property
Added enum PersistenceErrorCode for consumption by DocSvr
Made context-aware properties be explicit to the type of value and optional.
Added JsonPath property
Added MsappEntryFullPath property. only to be set when an entry is known.
Updated places where exceptions are thrown.
Added try/catches to YamlSerializer/YamlDeserializer to wrap YamlDotNet exceptions.
Updated MsappArchive to add context and error codes.
Updated unit tests to expect the new exception type.
Added fluent assertion extensions to make checking error code easier.
Fixed bug in RoundTripWriter dispose method which would hide original exception.
Fixed bug in return type of IYamlDeserializer.Deserialize so that it's nullable. This is the correct behavior of how YamlDotNet deserializes.
Added unit tests showing this behavior, that it's possible for the deserialized value to be null.
Removed check that would throw if theyaml is an empty string. This will get deserialized as a null value. Callers should be handling null results to avoid NullReferenceExceptions.
Problem
We need to standardize on the custom exceptions that we throw and allow the DocServer to emit actionable error messages to the user if possible.
Solution
This PR adapts our existing
PersistenceException
to require an ErrorCode and allows it to be used in more general scenarios. We also shore up the APIs for serializing/deserializing yaml and json to wrap exceptions coming from the serialization libraries.Changes
Added required
ErrorCode
propertyAdded enum
PersistenceErrorCode
for consumption by DocSvrMade context-aware properties be explicit to the type of value and optional.
Added
JsonPath
propertyAdded
MsappEntryFullPath
property. only to be set when an entry is known.Updated places where exceptions are thrown.
Added try/catches to YamlSerializer/YamlDeserializer to wrap YamlDotNet exceptions.
Updated MsappArchive to add context and error codes.
Updated unit tests to expect the new exception type.
Added fluent assertion extensions to make checking error code easier.
Fixed bug in
RoundTripWriter
dispose method which would hide original exception.Fixed bug in return type of
IYamlDeserializer.Deserialize
so that it's nullable. This is the correct behavior of how YamlDotNet deserializes.NullReferenceExceptions
.Validation
Tests updated and new ones added.