mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 20:02:20 +00:00
feat: add type to AbortError (#45)
This commit is contained in:
parent
b30ee5f6af
commit
4fd37bb616
@ -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()
|
||||
|
@ -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 = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user