1FactoryController.prototype.create = function (callback) {
2 //The throw is working, and the exception is returned.
3 throw new Error('An error occurred'); //outside callback
4 try {
5 this.check(function (check_result) {
6 callback(check_result);
7 });
8 } catch (ex) {
9 throw new Error(ex.toString());
10 }
11}
12
13FactoryController.prototype.create = function (callback) {
14 try {
15 this.check(function (check_result) {
16 //The throw is not working on this case to return the exception to the caller(parent)
17 throw new Error('An error occurred'); //inside callback
18 });
19 } catch (ex) {
20 throw new Error(ex.toString());
21 }
22}
1app.get('/', function (req, res, next) {
2 Promise.resolve().then(function () {
3 throw new Error('BROKEN')
4 }).catch(next) // Errors will be passed to Express.
5})
6