Skip to content

Commit

Permalink
fix(url parser): try catch bug, not actually returning from try loop
Browse files Browse the repository at this point in the history
Tests that threw an error would trigger the error block of the try/catch. Is rewritten now to avoid this but avoiding try/catch probably best in the long run with regards to callbacks.
  • Loading branch information
Jessica Lord committed Nov 20, 2017
1 parent 716dddb commit 758892b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/url_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ module.exports = function(url, options, callback) {
};

function parseHandler(address, options, callback) {
let result, err;
try {
const result = parseConnectionString(address, options);
return callback(null, result);
} catch (err) {
return callback(err);
result = parseConnectionString(address, options);
} catch (e) {
err = e;
}

return err ? callback(err, null) : callback(null, result);
}

function parseConnectionString(url, options) {
Expand Down

0 comments on commit 758892b

Please sign in to comment.