Jump to content
RAGE Multiplayer Community

NodeJS error handling


Recommended Posts

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 ?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 4 months later...

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


const module = require("app");

try {
}	catch (e) {
 	throw e; 


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

module.exports = Func;


Link to comment
Share on other sites

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...