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

Commit

Permalink
feat: add type to AbortError (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc authored and jacobheun committed Apr 18, 2019
1 parent b30ee5f commit 4fd37bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dial-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = (common) => {
await socket
} catch (err) {
expect(err.code).to.eql(AbortError.code)
expect(err.type).to.eql(AbortError.type)
return
}
expect.fail('Did not throw error with code ' + AbortError.code)
Expand All @@ -80,6 +81,7 @@ module.exports = (common) => {
await socket
} catch (err) {
expect(err.code).to.eql(AbortError.code)
expect(err.type).to.eql(AbortError.type)
return
} finally {
connector.restore()
Expand Down
5 changes: 5 additions & 0 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ class AbortError extends Error {
constructor () {
super('AbortError')
this.code = AbortError.code
this.type = AbortError.type
}

static get code () {
return 'ABORT_ERR'
}

static get type () {
return 'aborted'
}
}

module.exports = {
Expand Down

0 comments on commit 4fd37bb

Please sign in to comment.