fix: wrap newStream errors to improve debuggability

This commit is contained in:
Jacob Heun 2020-06-05 13:53:36 +02:00
parent aadeb73c94
commit 6bfd2c7c46
No known key found for this signature in database
GPG Key ID: CA5A94C15809879F
2 changed files with 2 additions and 1 deletions

View File

@ -253,7 +253,7 @@ class Upgrader {
return { stream: { ...muxedStream, ...stream }, protocol } return { stream: { ...muxedStream, ...stream }, protocol }
} catch (err) { } catch (err) {
log.error('could not create new stream', err) log.error('could not create new stream', err)
throw errCode(err, codes.ERR_UNSUPPORTED_PROTOCOL) throw errCode(new Error('Could not create a new stream'), codes.ERR_UNSUPPORTED_PROTOCOL, { cause: err })
} }
} }

View File

@ -339,6 +339,7 @@ describe('Upgrader', () => {
results.forEach(result => { results.forEach(result => {
expect(result.isRejected).to.equal(true) expect(result.isRejected).to.equal(true)
expect(result.reason.code).to.equal(codes.ERR_UNSUPPORTED_PROTOCOL) expect(result.reason.code).to.equal(codes.ERR_UNSUPPORTED_PROTOCOL)
expect(result.reason.cause).to.exist()
}) })
}) })
}) })