Skip to content

Replace ParseError/string errors with Error and use generally #2345

@KathleenDollard

Description

@KathleenDollard

See this comment for proposal

ParseError is currently a sealed internal class that is used only for parser errors and 'ParseResult.ParseErrors' is a ReadOnlyList.

A decision on this is necessary to test ErrorReporting without IVT (InternalsVisibleTo). IVT is not an acceptable way to do testing because ErrorReporting is a key extensibility point and alternate subsystems cannot use IVT.

We may choose to rename ParseError at the same time, but Error seems a rather broad name.

What is the value of restricting this. There are many kinds of errors, and a core purpose of this type is to report errors. Why not open up this collection and type to include all errors in the pipeline, including parsing, default value failures, validation failures, invocation failures and anything other errors the CLI author wants to communicate to the user.

Other thoughts:

  • Provenance (what caused it) of errors is valuable
  • Location of the error is important for better reporting
    • This needs to be position within the raw string received, which the shell may alter from user input. Error reporting can include the string as received as a mitigation. Collapsed whitespace is a potential difference.
  • Additional properties may be a point of future extension. We can handle this by unsealing the class (acknowledging the perf hit, but if you have errors is perf still a major issue?)
  • It would be nice for ParseError to be convertible to a Roslyn diagnostic. We don't want a Roslyn dependency in the subsystem layer, but there is likely to be a generation support layer, which could be viewed as a Roslyn support layer for all things.
    • This means we would have the information used by Roslyn on the ParseError - for example adding a error ID.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesignPowderhouseWork to isolate parser and features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions