-
-
Notifications
You must be signed in to change notification settings - Fork 284
Use Func to pass custom exception to Guard methods #350
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
Conversation
|
Just adding a note. This should have been into a v5.0.0 of the library, since it is a breaking change. The signature of all methods have changed, therefore depending packages which used v4.5.0 cannot find the old signature in the v4.6.0. The scenario where I found out this runtime exception is the following:
The application starts failing then when calling the package "A" because it cannot find the old method's signature in the current assembly. I have downgraded to v4.5.0 until the custom package "A" is also upgraded. |
|
Shoot, you're absolutely right. My error. I had meant to make the change to the signature in between releases, meaning that the short-lived version where the exception was added to the method signatures would never have been published. Thus, fixing that so that it took in an (optional) Func would have been an additive-only change and thus a minor release. Probably my best option at this point is to publish a v5 version just so (hopefully) folks jump to that from 4.x instead of to the mistakenly versioned 4.6 release. |
It changes the optional exception to a factory using Func.
From
Guard.Against.Empty(anEmptyString, exception: new SomethingWrongHappenedException());To
Guard.Against.Empty(anEmptyString, exceptionCreator: () => SomethingWrongHappenedException());It follows the same approach from 6186c68 in all other methods.
Relates to: #344