Closed bartelink closed 9 months ago
I do appreciate that there is a value in ArguParseException
being known and trusted to only be throwable indirectly by invoking Argu operations.
If the exception was a type
rather than an exception
, I'd be proposing a derived Exception type
as a solution that solves my desire to be able to filter with a single type check pattern, but I suspect that's a bridge too far.
Am absolutely interested in spike PRs that demonstrate cleaner ways to handle cases where e.g. I'm seeking to convey programmatically that that some combination of arguments are missing and/or illegal.
I ended up with a mix of ParseResults.Catch / Raise / GetResult in Equinox and Propulsion
https://github.com/jet/propulsion/blob/8349a25fd9abda31922210f710c716fcf190305c/tools/Propulsion.Tool/Args.fs#L33 https://github.com/jet/propulsion/blob/8349a25fd9abda31922210f710c716fcf190305c/tools/Propulsion.Tool/Infrastructure.fs#L13-L16 https://github.com/jet/propulsion/blob/8349a25fd9abda31922210f710c716fcf190305c/tools/Propulsion.Tool/Program.fs#L404
Ultimately if #143 had a complete answer, I would probably not be looking for anything here, and #187 is a reasonable half way house
Description
Would like a way to throw
ArguParseException
, either directly or indirectly via a helper.e.g.
missingArg
orinvalidCommand
ofstring -> 'a
that wouldraise (ArguParseException("ERROR: " + message))
or similarExpected behavior
Can handle 2% of cases where I determine that semantics have been contravened by the invocation, but can't represent that rule via attributes and/or Argu API calls
Actual behavior
Need to define my own exception for that, and then remember to handle it explicitly as I already need to for
ArguParseException
Known workarounds
In Equinox, Propulsion and some closed source apps, I and others have established a convention of having a secondary exception (
MissingArg
)