mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-25 12:52:35 +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
|
await socket
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).to.eql(AbortError.code)
|
expect(err.code).to.eql(AbortError.code)
|
||||||
|
expect(err.type).to.eql(AbortError.type)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
expect.fail('Did not throw error with code ' + AbortError.code)
|
expect.fail('Did not throw error with code ' + AbortError.code)
|
||||||
@ -80,6 +81,7 @@ module.exports = (common) => {
|
|||||||
await socket
|
await socket
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.code).to.eql(AbortError.code)
|
expect(err.code).to.eql(AbortError.code)
|
||||||
|
expect(err.type).to.eql(AbortError.type)
|
||||||
return
|
return
|
||||||
} finally {
|
} finally {
|
||||||
connector.restore()
|
connector.restore()
|
||||||
|
@ -4,11 +4,16 @@ class AbortError extends Error {
|
|||||||
constructor () {
|
constructor () {
|
||||||
super('AbortError')
|
super('AbortError')
|
||||||
this.code = AbortError.code
|
this.code = AbortError.code
|
||||||
|
this.type = AbortError.type
|
||||||
}
|
}
|
||||||
|
|
||||||
static get code () {
|
static get code () {
|
||||||
return 'ABORT_ERR'
|
return 'ABORT_ERR'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get type () {
|
||||||
|
return 'aborted'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user