Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.

Commit f39df63

Browse files
author
Joe Hand
authored
Merge pull request #8 from martinheidegger/bubble-errors
Preventing catching of errors in the callback.
2 parents eafd04f + d505ef1 commit f39df63

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ function resolve (link, cb) {
1616
// validates + removes dat://
1717
// also works for http urls with keys in them
1818
key = stringKey(link)
19-
cb(null, key)
2019
} catch (e) {
2120
lookup()
21+
return
2222
}
23+
cb(null, key)
2324

2425
function lookup () {
2526
// if it starts with http or dat: use as is, otherwise prepend http://

test/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,13 @@ test('resolve beaker browser dat', function (t) {
118118
t.end()
119119
})
120120
})
121+
122+
test('callbacks are called out of a try/catch block', function (t) {
123+
process.once('uncaughtException', function (err) {
124+
t.equals(err.message, 'test', 'Making sure that the right error occurs')
125+
t.end()
126+
})
127+
datResolve('dat://beakerbrowser.com', function () {
128+
throw new Error('test')
129+
})
130+
})

0 commit comments

Comments
 (0)