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

Unwrapping of AggregateExceptions #1041

merged 1 commit into from May 26, 2019


Copy link

@jnyrup jnyrup commented May 5, 2019

After #1038 got merged, the logic for unwrapping AggregateException becomes a lot easier, as we now know that FluentAssertions doesn't wrap exceptions in an AggregateException.

Calling Throw<TException> is designed to also succeed if an exception of type TException is wrapped inside an AggregateException.
The same behavior should be present for NotThrow<TException>

This PR solves these problems.

  1. NotThrow<TException> didn't look inside AggregateExceptions to see if an exception of type TException was thrown, which made it non-symmetric to Throw<TException>.
  2. GetFirstNonAggregateException only looked at the InnerException of an AggregateException instead of InnerExceptions (all wrapped exceptions). E.g. it failed to handle if TException was the second InnerException.
  3. As we no longer unnecessarily wrap exceptions, InterceptException unwrapped to much.

@jnyrup jnyrup requested a review from dennisdoomen May 5, 2019 11:28
Copy link

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

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

I can't fully predict the effect of these changes. I'll try to run these changes to my current project code-base to see if anything breaks.

Copy link
Member Author

jnyrup commented May 5, 2019

Found a related issue #696

Copy link

Tried to run this PR against the 20K tests of a project I'm involved with and everything seems to be fine.

@dennisdoomen dennisdoomen merged commit 34f4ce1 into fluentassertions:master May 26, 2019
@jnyrup jnyrup deleted the NotThrow branch May 26, 2019 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants