Skip to content

Remove CommandLineConfigurationException #1909

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

Open
Tracked by #1891
jonsequitur opened this issue Nov 2, 2022 · 5 comments
Open
Tracked by #1891

Remove CommandLineConfigurationException #1909

jonsequitur opened this issue Nov 2, 2022 · 5 comments
Labels
Milestone

Comments

@jonsequitur
Copy link
Contributor

jonsequitur commented Nov 2, 2022

    // Is this something people actually need to catch?  If not, consider not making it public.
    // And if they do need to catch it, is it actually different enough from any existing exception to warrant a new type?
    public class CommandLineConfigurationException : Exception, System.Runtime.Serialization.ISerializable 
@jonsequitur jonsequitur mentioned this issue Nov 2, 2022
56 tasks
@adamsitnik adamsitnik self-assigned this Nov 4, 2022
@adamsitnik
Copy link
Member

I am not sure which exception we should use instead:

  • ValidationException has the right name, but it does not support .NET Standard 2.0 and it might end up creating unnecessary dependency
  • dictionary throws ArgumentException when a duplicate is being added, but here the exception does not refer to the argument provided to the method, rather to the state of the validate object

@KalleOlaviNiemitalo
Copy link

CommandLineConfigurationException is thrown for two possible errors:

Some candidates from .NET Standard 2.0:

InvalidOperationException seems best.

@jonsequitur
Copy link
Contributor Author

I think that we went down this same path before giving up and deciding to use a custom exception type. InvalidOperationException feels a little wrong here because it would imply that the CommandLineConfiguration instance is not in the correct state to be validated.

@KalleOlaviNiemitalo
Copy link

Did Stream.ObjectInvariant() ever throw anything?

@KalleOlaviNiemitalo
Copy link

InvalidOperationException feels a little wrong here because it would imply that the CommandLineConfiguration instance is not in the correct state to be validated.

If the method were instead called RequireValid then InvalidOperationException would feel less wrong.

Another option is to return the error instead of throwing it. Unfortunately ValidationResult is not in .NET Standard 2.0 either.

Is something like public string Validate() used anywhere else? Windows Forms has ErrorProvider with string GetError(Control) but that just retrieves a previously stored error string instead of validating any data during the call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants