Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
705 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict'
|
---|
| 2 | class FetchError extends Error {
|
---|
| 3 | constructor (message, type, systemError) {
|
---|
| 4 | super(message)
|
---|
| 5 | this.code = 'FETCH_ERROR'
|
---|
| 6 |
|
---|
| 7 | // pick up code, expected, path, ...
|
---|
| 8 | if (systemError)
|
---|
| 9 | Object.assign(this, systemError)
|
---|
| 10 |
|
---|
| 11 | this.errno = this.code
|
---|
| 12 |
|
---|
| 13 | // override anything the system error might've clobbered
|
---|
| 14 | this.type = this.code === 'EBADSIZE' && this.found > this.expect
|
---|
| 15 | ? 'max-size' : type
|
---|
| 16 | this.message = message
|
---|
| 17 | Error.captureStackTrace(this, this.constructor)
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | get name () {
|
---|
| 21 | return 'FetchError'
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | // don't allow name to be overwritten
|
---|
| 25 | set name (n) {}
|
---|
| 26 |
|
---|
| 27 | get [Symbol.toStringTag] () {
|
---|
| 28 | return 'FetchError'
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 | module.exports = FetchError
|
---|
Note:
See
TracBrowser
for help on using the repository browser.