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}
1TypeError: res.send is not a function at C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\app.js:6:9 at Layer.handle [as handle_request] (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\layer.js:95:5) at C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\index.js:281:22 at Function.process_params (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\index.js:335:12) at next (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\index.js:275:10) at expressInit (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\middleware\init.js:40:5) at Layer.handle [as handle_request] (C:\Users\ARAZ\Desktop\H\REact\nodeJS-Practice\node-express-course\02-express-tutorial\node_modules\express\lib\router\layer.js:95:5)