Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"test:flow": "flow check",
"test:tcp": "tape-ext test/TCPSocket",
"test:api": "tape-ext test/API",
"test:dns-sd": "tape-ext test/ServiceDiscovery",
"precommit": "lint-staged",
"demo": "cross-env MOZ_DISABLE_CONTENT_SANDBOX=1 web-ext run --firefox=nightly --browser-console --url about:debugging",
"demo:discovery": "cross-env MOZ_DISABLE_CONTENT_SANDBOX=1 web-ext run --firefox=nightly --browser-console --url about:debugging --source-dir demo/discovery",
Expand Down
10 changes: 6 additions & 4 deletions src/ServiceDiscovery/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ interface Host {
}
}

const notFound = new ExtensionError("Host for the object not found")
const notFound = new context.cloneScope.RangeError(
"Host for the object not found"
)
let notFoundPromiseCache = null

const notFoundPromise = () => {
Expand Down Expand Up @@ -159,7 +161,7 @@ interface Host {

resolve(service)
} catch (error) {
reject(new ExtensionError(error))
reject(new cloneScope.Error(error.message))
}
})
}
Expand Down Expand Up @@ -280,14 +282,14 @@ interface Host {
switch (message.type) {
case "onStopDiscoveryFailed": {
return this.throw(
new ExtensionError(
new context.cloneScope.Error(
`Failed to stop discovery ${message.errorCode}`
)
)
}
case "onStartDiscoveryFailed": {
return this.throw(
new ExtensionError(
new context.cloneScope.Error(
`Failed to start discovery ${message.errorCode}`
)
)
Expand Down
16 changes: 16 additions & 0 deletions test/ServiceDiscovery/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,19 @@ test("discovery with attributes", async test => {
await announcement
await discovery
})

test("unwrappable exceptions #67", async test => {
try {
const service = await browser.ServiceDiscovery.announce({
name: "error",
type: "boom",
protocol: "crash"
})
test.fail(`Exception was expected on wrong protocol`)
} catch (error) {
test.ok(
error.message.includes(`must be either "udp" or "tcp"`),
"error is unwrappable"
)
}
})