Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upstandard way to ignore an error #620
Comments
This comment has been minimized.
This comment has been minimized.
In any case, agreed. My go-to for ignoring errors is: mkdirp('/dir/might/exist', () => {
doStuff()
})Quite literally... waves hand "there is no error". |
This comment has been minimized.
This comment has been minimized.
|
@dcousens what if you need to access the other arguments? Yeah I personally wish that particular case were detectable to and required some explicit signal that you hadn't inadvertently invited chaos into your program by forgetting to handle the |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I suppose I just use |
This comment has been minimized.
This comment has been minimized.
|
I think |
This comment has been minimized.
This comment has been minimized.
|
Yeah, |
feross
added
the
question
label
Sep 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Closing, since discussion has concluded |
timoxley commentedSep 13, 2016
This is mostly just a discussion item rather than a serious issue.
Currently
standarduses handle-callback-err which complains if you do not "handle" callback errors.Sometimes you do want to not handle an error e.g. ignore
mkdirperrors.The current rule is good as it encourages you to explicitly flag intentionally ignored errors rather than just leaving the future reader wondering whether the error was left ignored accidentally or for some purpose.
Even prior to using standard, I try to always flag explicitly ignored errors with a comment like so
This only changed slightly upon starting to use standard:
Another option could be to use a different variable name for ignored errors:
Does anyone else have a standard pattern they use for flagging "ignored" errors?
It's a possibility that even with the comment this is still a crappy workaround and I really should be explicitly whitelisting the
error.code === 'EEXIST'case andthrow err/return callback(err)otherwise.Note that it's also still valid to not add any comment, which makes it again unclear whether the error is being ignored intentionally or not:
This should perhaps be disallowed.
In fact, I'm not sure there's any valid reason for a statement to solely contain a reference to a variable like that since it's a noop so perhaps I'm really requesting a rule for something like "no useless statements".