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

Commit 4fd37bb

Browse files
dirkmcjacobheun
authored andcommitted
feat: add type to AbortError (#45)
1 parent b30ee5f commit 4fd37bb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/dial-test.js

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module.exports = (common) => {
6262
await socket
6363
} catch (err) {
6464
expect(err.code).to.eql(AbortError.code)
65+
expect(err.type).to.eql(AbortError.type)
6566
return
6667
}
6768
expect.fail('Did not throw error with code ' + AbortError.code)
@@ -80,6 +81,7 @@ module.exports = (common) => {
8081
await socket
8182
} catch (err) {
8283
expect(err.code).to.eql(AbortError.code)
84+
expect(err.type).to.eql(AbortError.type)
8385
return
8486
} finally {
8587
connector.restore()

src/errors.js

+5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ class AbortError extends Error {
44
constructor () {
55
super('AbortError')
66
this.code = AbortError.code
7+
this.type = AbortError.type
78
}
89

910
static get code () {
1011
return 'ABORT_ERR'
1112
}
13+
14+
static get type () {
15+
return 'aborted'
16+
}
1217
}
1318

1419
module.exports = {

0 commit comments

Comments
 (0)