1'use strict' 2 3/** 4 * fetch-error.js 5 * 6 * FetchError interface for operational errors 7 */ 8 9/** 10 * Create FetchError instance 11 * 12 * @param String message Error message for human 13 * @param String type Error type for machine 14 * @param String systemError For Node.js system error 15 * @return FetchError 16 */ 17module.exports = FetchError 18function FetchError (message, type, systemError) { 19 Error.call(this, message) 20 21 this.message = message 22 this.type = type 23 24 // when err.type is `system`, err.code contains system error code 25 if (systemError) { 26 this.code = this.errno = systemError.code 27 } 28 29 // hide custom error implementation details from end-users 30 Error.captureStackTrace(this, this.constructor) 31} 32 33FetchError.prototype = Object.create(Error.prototype) 34FetchError.prototype.constructor = FetchError 35FetchError.prototype.name = 'FetchError' 36