Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Add type to AbortError #45

Merged
merged 1 commit into from
Apr 18, 2019
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
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