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

Changed message of exception to improve readability #1306

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

C0DK
Copy link

@C0DK C0DK commented Nov 16, 2021

Hey - I don't mean to be an annoying "You have a error" because I make those all the time; I simply wanted to help.

I got the following exception from this great framework:

AutoFixture.Idioms.GuardClauseException : An attempt was made to assign the value to the parameter "redispatchSeries" of the method ".ctor", and Guard Clause prevented it, however the thrown exception contains invalid parameter name. Ensure you pass correct parameter name to the ArgumentNullException constructor.
Expected parameter name: redispatchSeries
Actual parameter name: unitId

And realized it lacked an "a" between

AutoFixture.Idioms.GuardClauseException : [...] method ".ctor", and >a< Guard Clause prevented it[...]

So I wanted to fix those.

However, upon creating this pull request, my subscription to Grammarly proposed a few other changes, which I've added in a separate commit, which contains those changes.

After doing these changes I tried to live by the Boy Scout Rule, and DRY the creation of these exceptions, as well as implement it for EmptyGuid, which I realize didn't check param name.

@aivascu
Copy link
Member

aivascu commented Nov 18, 2021

Hello @C0DK ,
Thank you for submitting the PR.
Indeed there are some typos in the codebase, that have crept in over time.
I'll try to have a look at your PR in the next couple days. Until then please have a look at the build errors on AppVeyor.
You can also have a look at the contributing guide, to learn about the code style and workflow used in the project.

Removed trailing whitespaces.

remove extra whitespace

Fixed failing tests
@C0DK
Copy link
Author

C0DK commented Nov 23, 2021

@aivascu Thank you. I never got around to answering you, but I've fixed the issues now.

Love the framework, and felt like it was a good way to show it, by helping out a bit. I hope the PR doesn't break the SRP too much by both doing some boy scouting + proofreading. Luckily they are separate commits, and we can just drop some if you guys disagree.

@C0DK
Copy link
Author

C0DK commented Dec 7, 2021

@aivascu do you have time to check this? :)

"<null>",
string.Format(CultureInfo.InvariantCulture,
"Guard Clause prevented it, however the thrown exception contains invalid parameter name. " +
"Ensure you pass correct parameter name to the ArgumentNullException constructor.{0}" +
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this assertion will not report anymore the correct exception type. You might add the exception type as an argument for the exception factory. Looks like current tests did not assert this behavior. Could you add the appropriate tests?

Copy link
Author

Choose a reason for hiding this comment

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

What wrong exception? I am not sure I follow.

Copy link
Member

Choose a reason for hiding this comment

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

@C0DK on line 62 it says ArgumentNullException. In the method that replaces this code block, the exception that's mentioned is ArgumentException.

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.

None yet

2 participants