When I use try catch structure My code give me err to less detail Like that
[UnhandledPromiseRejection: This error originated eith{
code: 'ERR_UNHANDLED_REJECTION'
}
But in reality its give me like that
parsedHtmlPage.querySelectorAll('*').forEach((el{
^
TypeError: indexObject.img is not iterable
at D:\githubprojects\projectMovieSite\dizitest\src7
at Array.forEach (<anonymous>)
at findEmptyDataInCompiledData (D:\githubprojects\)
at processTicksAndRejections (node:internal/proces)
at async D:\githubprojects\projectMovieSite\dizite8
PS D:\githubprojects\projectMovieSite\dizitest>
my catch in func
catch (err) {
logger.error(`${err}`)
throw Error
}
How can I take detail log when I use try catch?
I tried to explain my try catch problem
Maybe try this.
catch (err) {
logger.error(`${err}`);
if(err.stack){
logger.info(err.stack);
}
throw err;
}
Also you all the error instance has it's own field named stack.