1'use strict' 2class 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 12 this.errno = this.code 13 14 // override anything the system error might've clobbered 15 this.type = this.code === 'EBADSIZE' && this.found > this.expect 16 ? 'max-size' : type 17 this.message = message 18 Error.captureStackTrace(this, this.constructor) 19 } 20 21 get name () { 22 return 'FetchError' 23 } 24 25 // don't allow name to be overwritten 26 set name (n) {} 27 28 get [Symbol.toStringTag] () { 29 return 'FetchError' 30 } 31} 32module.exports = FetchError 33