Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
fix: ensure dial is rejected with an Error (#199)
Browse files Browse the repository at this point in the history
* fix: ensure dial is rejected with an Error

`offer.err` is returned as a string, convert it to an Error

* refactor: update error code

Co-Authored-By: Jacob Heun <[email protected]>

Co-authored-by: Jacob Heun <[email protected]>
  • Loading branch information
achingbrain and jacobheun authored Feb 3, 2020
1 parent dbfd6b1 commit 41f278e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class WebRTCStar {
// are clueless as to why.
sioClient.on('ws-handshake', (offer) => {
if (offer.intentId === intentId && offer.err) {
reject(offer.err)
reject(errcode(offer.err instanceof Error ? offer.err : new Error(offer.err), 'ERR_SIGNALLING_FAILED'))
}

if (offer.intentId !== intentId || !offer.answer) {
Expand Down
3 changes: 2 additions & 1 deletion test/transport/dial.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ module.exports = (create) => {
try {
await ws1.dial(maOffline)
} catch (err) {
expect(err).to.exist()
expect(err).to.be.an.instanceOf(Error)
expect(err).to.have.property('code', 'ERR_SIGNALLING_FAILED')
return
}

Expand Down

0 comments on commit 41f278e

Please sign in to comment.