throw new Error node code example
Example 1: node js throw error
FactoryController.prototype.create = function (callback) {
throw new Error('An error occurred');
try {
this.check(function (check_result) {
callback(check_result);
});
} catch (ex) {
throw new Error(ex.toString());
}
}
FactoryController.prototype.create = function (callback) {
try {
this.check(function (check_result) {
throw new Error('An error occurred');
});
} catch (ex) {
throw new Error(ex.toString());
}
}
Example 2: javascript throw new error
throw new Error("Error message here");
Example 3: js throw new error
throw new Error("message");
Example 4: error handling in node js
app.get('/', function (req, res, next) {
Promise.resolve().then(function () {
throw new Error('BROKEN')
}).catch(next)
})