-
Notifications
You must be signed in to change notification settings - Fork 10
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
Establish error message approach #6
Comments
Let's try to mirror what Node does in a minimal fashion but could be easily ported over when/if the time comes. |
Another question in today's meeting: Should we ever The consensus is we should avoid throwing an error and prefer to return an error object and allow the consumer of parseargs to manage error handling. |
Typically I throw a string from argument validation, because throwing an error causes node to print stack trace info that's undesirable. It would also be fine to let the consumer handle it, but since there's no robust way of identifying error objects, i'd prefer a two-channel mechanism like Promise. |
For my command-line work, I make a distinction between errors which are due to programmer error and errors which are encountered at runtime due to usage errors on the command line. For the programmer errors I throw |
In my yargs packages i throw strings instead of errors for arg validation, for that reason. |
I think it's less important that we figure out the wording of errors, when we merge into the Node.js codebase we will model after other errors... More importantly, I like @shadowspawn's suggestion that we go through the codebase and determine which errors could be categorized as input errors, vs., programming errors, and decide how we handle each:
|
There have been a few people suggesting that parse never "fails" on user input, and perhaps error information could be a property in the results. I see the attraction and interested in trying that approach. [Edit: I am no longer interested in quietly returning errors, doubtful it will be useful enough.] In line with the description and intent of (I am personally of the view that if the input does not match the programmers intentions then the outcome is in doubt. But a key part of the proposal is zero-setup parsing, and I can turn on strict to get more certainty.) |
Move to Node.js style errors and validation to make it easier to drop into Node codebase. Fixes #6
See: #1 (comment)
The text was updated successfully, but these errors were encountered: