-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.1.13
-
Component/s: Core
-
Empty show more show less
the code below
var uri = 'mongodb://undefined@cluster0-shard-00-'; (async function() { let db; try { db = await MongoClient.connect(uri, { useNewUrlParser: true }); console.log("RETURN", db); } catch (err){ console.log('EXITING'); process.exit(1); } }());
fails to catch the error generated. the error owes to the undefined value of the credentials and if replaced with
var uri = 'mongodb://x:y@cluster0-shard-00-';
produces an exception about authentication failure as expected but the absence of a colon in the credentials causes an untrappable error
the problem is that the caller reasonably expects to be able to trap any issue without having to resort to the uncaughtException mechanism in Javascript
A link to my original post can be found here: https://stackoverflow.com/questions/54737280/catch-fails-on-connection-to-mongo