An example from node.js documentation:
fs.writeFile('message.txt', 'Hello Node.js', (err) => {
if (err) throw err;
console.log('The file has been saved!');
});
This looks like a common way to handle errors when the first parameter is
an instance of Error.
Yes, this line of code is short and easy to copy-paste.
But introducing something like this:
fs.writeFile('message.txt', 'Hello Node.js', (err) => {
throwif err;
console.log('The file has been saved!');
});
would make the code much cleaner and bring some sort of standart way to
handle such errors.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss