feat: add type to AbortError (#45)

This commit is contained in:
dirkmc 2019-04-18 18:44:17 +08:00 committed by Jacob Heun
parent b30ee5f6af
commit 4fd37bb616
2 changed files with 7 additions and 0 deletions

View File

@ -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)
@ -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()

View File

@ -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 = {