I have the following Javascript code
main.js
'use-strict';
const assert = require('assert');
var r = require('./index.js');
async function fun() {
try {
r.start();
} catch (e) {console.log(e);}
}
fun();
index.js
'use-strict';
var assert = require('assert');
async function start() {
assert.ok(1==0);
}
exports.start = start;
Now the exception thrown in index.js
is NOT caught in main.js
, why so ? Is there any way I can facilitate this ?
I have a series of functions in different files invoked from main.js and I don't want to put try/catch in all of them.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…