Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Better errors for your NodeJS code.
First, require me where you could throw errors:
var YError = require('yerror');
Then, emit errors with a bonus: parameters!
function doSomething(pay, action) {
if(parseInt(pay, 10) !== pay) {
throw new YError('E_BAD_PAY', pay, action);
}
}
doSomething('nuts', 'code');
// YError: E_BAD_PAY (nuts, code)
// at doSomething (/home/nfroidure/simplifield/yerror/test.js:5:11)
// at Object.<anonymous> (/home/nfroidure/simplifield/yerror/test.js:9:1)
// (...)
You don't have to use constant like error messages, we use this convention mainly for i18n reasons.
Also, you could want to wrap errors and keep a valuable stack trace:
function doSomethingAsync(pay, action) {
return new Promise(function(resolve, reject) {
try {
doSomething(pay, action);
resolve();
} catch(err) {
reject(YError.bump(err));
}
});
}
doSomethingAsync('nuts', 'code')
.catch(function(err) {
console.log(err.stack);
});
// YError: E_BAD_PAY (nuts, code)
// at doSomething (/home/nfroidure/simplifield/yerror/test.js:5:11)
// (...)
// YError: E_BAD_TRANSACTION (pay)
// at Function.YError.wrap (/home/nfroidure/simplifield/yerror/src/index.js:41:12)
// at /home/nfroidure/simplifield/yerror/test.js:16:21
// at doSomethingAsync (/home/nfroidure/simplifield/yerror/test.js:11:11)
// (...)
Creates a new YError with msg
as a message and args
as debug values.
Wraps any error and output a YError with msg
as its message and args
as
debug values.
Return YError as is or wraps any other error and output a YError with msg
as
its message and args
as debug values.
Same than YError.wrap()
but preserves the message and the debug values of the
YError errors.
FAQs
It helps to know why you got an error.
We found that yerror demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.