Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Map Extension Method to Support Mapping from Result<T> to Result #213

Merged
merged 6 commits into from
Oct 28, 2024

Conversation

jmrtnz94
Copy link
Contributor

@jmrtnz94 jmrtnz94 commented Oct 9, 2024

See #212

case ResultStatus.Conflict: return result.Errors.Any()
? Result.Conflict(result.Errors.ToArray())
: Result.Conflict();
case ResultStatus.CriticalError: return Result.CriticalError(result.Errors.ToArray());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need the correlation id as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CriticalError accepts a string[], so we cannot pass in the correlation id. See https://github.com/ardalis/Result/blob/main/src/Ardalis.Result/Result.cs#L223.

While Error accepts an ErrorList object that contains correlation id. See https://github.com/ardalis/Result/blob/main/src/Ardalis.Result/Result.cs#L123-L127

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we're in a bit of a transition phase to using the ErrorList class in more places but ideally we'd use the constructors that accept a CorrelationId wherever possible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have verified the CorrelationId property is propagated through the constructors where it is available. We can open another issue to add CorrelationId to the remaining constructors and then update these helper methods as needed.

KyleMcMaster

This comment was marked as off-topic.

Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
Ardalis.Result 67% 53% 264
Summary 67% (265 / 397) 53% (92 / 172) 264

@KyleMcMaster KyleMcMaster mentioned this pull request Oct 27, 2024
@ardalis ardalis merged commit 74c1a48 into ardalis:main Oct 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants