Jump to content

Recommended Posts

Posted

Hello,
It seems that actually every errors like undefined variables are not throwing any errors and simply avoid the next code execution,
After finishing a big module it's very annoying to debug line by line with console.logs when you can have a working debugger.. ahah
I'm not able to catch any errors using the process error EventEmitter,
Do someone have a solution to enable error throwing / debugging ?

Posted (edited)

Try to use assert in your code.
For example:
 

let tmp = 1;
let untmp;
console.assert(untmp != undefined, "assertion falied."); // console : assertion failed.
console.assert(tmp != undefined, "assertion failed"); // console : nothing

 

Edited by biostunt
  • 4 months later...
Posted

My issue was an error event that wasn't triggered,in a called subfunction.
I solved it by using a try catch

index.js

const module = require("app");

try {
	module();
}	catch (e) {
 	throw e; 
  	process.exit();
}


app.js

function Func() {
	klfhqirhgojgre() // this is undefined
}

module.exports = Func;

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...