Skip to content

Improve reporting the subject when chaining Throw and Which#3160

Merged
dennisdoomen merged 1 commit intofluentassertions:mainfrom
dennisdoomen:fix/871-exception-chaining
Feb 21, 2026
Merged

Improve reporting the subject when chaining Throw and Which#3160
dennisdoomen merged 1 commit intofluentassertions:mainfrom
dennisdoomen:fix/871-exception-chaining

Conversation

@dennisdoomen
Copy link
Copy Markdown
Member

@dennisdoomen dennisdoomen commented Feb 21, 2026

This commit improves caller/subject identification for chained assertions, especially in exception assertions, by allowing the chain to prepend a custom prefix to the generated caller identifier.

throwingAction.Should().Throw<SomeException>().Which.Property.Should().Be("Value");

will now report

Expected SomeException.Property to be a match with the expectation, but it differs at index 0:

Notice the name of the exception type.

Closes #871

@dennisdoomen dennisdoomen force-pushed the fix/871-exception-chaining branch from 0f6e84c to 63d0829 Compare February 21, 2026 21:16
@dennisdoomen dennisdoomen added this to the 8.9 milestone Feb 21, 2026
@dennisdoomen dennisdoomen merged commit 268fee5 into fluentassertions:main Feb 21, 2026
5 checks passed
@dennisdoomen dennisdoomen deleted the fix/871-exception-chaining branch February 21, 2026 21:17
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 21, 2026

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

This was referenced Mar 16, 2026
This was referenced Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error message generation does not work very well for throw cases

1 participant