Skip to content

Commit

Permalink
refactor: implement GetHashCode for ParsingFailure (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d authored Sep 14, 2023
1 parent 8372d9f commit 2bfc4e1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Vonage.Common/Failures/ParsingFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Vonage.Common.Failures;

/// <inheritdoc />
public override bool Equals(object obj) =>
obj is ParsingFailure failure && this.failures.SequenceEqual(failure.failures);
obj is ParsingFailure failure && this.GetHashCode().Equals(failure.GetHashCode());

/// <summary>
/// Creates a ParsingFailure from a list of failures.
Expand All @@ -30,6 +30,9 @@ public override bool Equals(object obj) =>
public string GetFailureMessage() =>
$"Parsing failed with the following errors: {string.Join(", ", this.failures.Select(failure => failure.GetFailureMessage()))}.";

/// <inheritdoc />
public override int GetHashCode() => this.GetFailureMessage().GetHashCode();

/// <inheritdoc />
public Exception ToException() => new VonageException(this.GetFailureMessage());

Expand Down

0 comments on commit 2bfc4e1

Please sign in to comment.