fetch-error.js 705 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict'
  2. class FetchError extends Error {
  3. constructor (message, type, systemError) {
  4. super(message)
  5. this.code = 'FETCH_ERROR'
  6. // pick up code, expected, path, ...
  7. if (systemError)
  8. Object.assign(this, systemError)
  9. this.errno = this.code
  10. // override anything the system error might've clobbered
  11. this.type = this.code === 'EBADSIZE' && this.found > this.expect
  12. ? 'max-size' : type
  13. this.message = message
  14. Error.captureStackTrace(this, this.constructor)
  15. }
  16. get name () {
  17. return 'FetchError'
  18. }
  19. // don't allow name to be overwritten
  20. set name (n) {}
  21. get [Symbol.toStringTag] () {
  22. return 'FetchError'
  23. }
  24. }
  25. module.exports = FetchError