Skip to content

Commit 758892b

Browse files
author
Jessica Lord
committed
fix(url parser): try catch bug, not actually returning from try loop
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.
1 parent 716dddb commit 758892b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/url_parser.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ module.exports = function(url, options, callback) {
4747
};
4848

4949
function parseHandler(address, options, callback) {
50+
let result, err;
5051
try {
51-
const result = parseConnectionString(address, options);
52-
return callback(null, result);
53-
} catch (err) {
54-
return callback(err);
52+
result = parseConnectionString(address, options);
53+
} catch (e) {
54+
err = e;
5555
}
56+
57+
return err ? callback(err, null) : callback(null, result);
5658
}
5759

5860
function parseConnectionString(url, options) {

0 commit comments

Comments
 (0)