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 upRequire using Error objects as Promise rejection reasons (prefer-promise-reject-errors) #777
Comments
feross
added
the
enhancement
label
Feb 8, 2017
feross
added this to the
standard v9 milestone
Feb 8, 2017
feross
added a commit
to standard/eslint-config-standard
that referenced
this issue
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
|
This will be part of standard v9. Only one repo was affected, and it contained code like this: if (typeof travisConfig.node_js === 'undefined') {
logger.error('node_js field not found in travis configuration')
return Promise.reject()
}Rejected promises should contain reasons, or they are very difficult to debug. That line should be: return Promise.reject(new Error('node_js field not found in travis configuration')) |
feross
closed this
Feb 9, 2017
feross
added a commit
to standard/eslint-config-standard
that referenced
this issue
Feb 9, 2017
lock
bot
locked as resolved and limited conversation to collaborators
May 10, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
feross commentedFeb 8, 2017
This rule aims to ensure that Promises are only rejected with
Errorobjects.It is considered good practice to only pass instances of the built-in
Errorobject to thereject()function for user-defined errors in Promises.Errorobjects automatically store a stack trace, which can be used to debug an error by determining where it came from. If a Promise is rejected with a non-Errorvalue, it can be difficult to determine where the rejection occurred.http://eslint.org/docs/rules/prefer-promise-reject-errors
Rule: