I have a function named inner that executes a series of asynchronous operations:
function inner(input) {
return step1(input)
.then(step2)
.then(step3)
.catch((e) => {
throw e
})
}
I propagate the error from inner so I can manage it at the caller level.
Take a look at this simple example:
app.get('/', function(req, res){
inner(req)
.then(result => {
res.render('foo', result)
}).catch((e) => {
res.render('error', e);
//eventually this would be changed to logger.error(e)
console.log(e);
})
})
The issue is that when logging the error, only the stack trace displays the inner function but not the calling file. If I were to use this function multiple times in my code and an error occurs, I would need to identify which section of my code invoked it.
Is there a way to include caller information in the error stack trace?