Skip to content

Commit

Permalink
addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mizrael committed Sep 10, 2024
1 parent be11c41 commit 5e3dc29
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Persistence/PaYaml/Serialization/PaYamlSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ private static void WriteTextWriter<TValue>(TextWriter writer, in TValue? value,

return value;
}
catch (YamlException ex) when (ex.InnerException is ArgumentException && ex.InnerException.Message.Contains("An item with the same key has already been added"))
{
throw PersistenceLibraryException.FromYamlException(ex, PersistenceErrorCode.DuplicateNameInSequence);
}
catch (YamlException ex)
{
throw PersistenceLibraryException.FromYamlException(ex, PersistenceErrorCode.YamlInvalidSyntax);
var errorCode = PersistenceErrorCode.YamlInvalidSyntax;
if (ex.InnerException is ArgumentException && ex.InnerException.Message.Contains("An item with the same key has already been added"))
errorCode = PersistenceErrorCode.DuplicateNameInSequence;

throw PersistenceLibraryException.FromYamlException(ex, errorCode);
}

// TODO: Consider using FluentValidation nuget package to validate the deserialized object
Expand Down

0 comments on commit 5e3dc29

Please sign in to comment.