This project is read-only.

Exceptions leaking over a try{} catch{}

Dec 31, 2013 at 7:54 PM
I am an npm package (Brian C's excellent PostGresSQL) which has also has a package called pg-query.

pg-query checks to see which flavor of pg is installed. I have only pg.js not pg. But this try is raising an event, which is caught by the debugger as an exception. Is that the expected behavior? I did not see any way to configure DEBUG/Exceptions... to avoid this.
try {
  var pg = require('pg');
} catch(e) {
  try {
    var pg = require('pg.js');
  } catch(e) {
    throw new Error("Could not require pg or pg.js - please install one or the other")
  }
}
Jan 2, 2014 at 4:20 AM
This is a default behavior, to disable it go to: Debug -> Exceptions (ALT+CTRL + E), look for nodejs exceptions.
Jan 2, 2014 at 4:56 PM
Yes, I read all your documentation and videos (and I saw this), But which one should I turn off (everything is on except syntax errors). I only want to suppress the load error from the require.

I am looking forward to the feature you are planning to have only exceptions from local (non NPM) modules that I write.

But also consider only leaking exceptions when they are of the form:
process.on('uncaughtException', function (err) { ... }

since obviously, if I have a catch {} it means I want to respond to the error in code, an not have it bubble out to the user or debugger.