1try {
2 throw "I'm Md Abdur Rakib"
3 console.log("You'll never reach to me", 123465)
4} catch (e) {
5 console.log(e); // I'm Md Abdur Rakib
6}
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}
1try {
2 throw new Error('Whoops!')
3} catch (e) {
4 console.error(e.name + ': ' + e.message)
5}
6