Skip to content

Remove CommandLineConfigurationException #1909

Closed

Description

@jonsequitur
    // 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 

Activity

  1. self-assigned this
    on Nov 4, 2022
  2. adamsitnik commented on Nov 4, 2022

    @adamsitnik
    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
  3. KalleOlaviNiemitalo commented on Nov 4, 2022

    @KalleOlaviNiemitalo

    CommandLineConfigurationException is thrown for two possible errors:

    Some candidates from .NET Standard 2.0:

    InvalidOperationException seems best.

  4. added a commit that references this issue on Nov 4, 2022
    8cd7268
  5. jonsequitur commented on Nov 4, 2022

    @jonsequitur
    ContributorAuthor

    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.

  6. KalleOlaviNiemitalo commented on Nov 4, 2022

    @KalleOlaviNiemitalo

    Did Stream.ObjectInvariant() ever throw anything?

  7. KalleOlaviNiemitalo commented on Nov 5, 2022

    @KalleOlaviNiemitalo

    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.

  8. added this to the 2.0 GA milestone on Nov 9, 2022
  9. removed their assignment
    on Mar 31, 2023
  10. modified the milestones: 2.0.0, Triage on Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions