1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 1x 1x 57x 1x 1x | 'use strict'; var RETRIABLE_ERRORS = ['ECONNRESET', 'ENOTFOUND', 'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED', 'EHOSTUNREACH', 'EPIPE', 'EAI_AGAIN']; var _ = require('lodash'); /** * @param {Null | Object} err * @param {Object} response * @return {Boolean} true if the request had a network error */ function NetworkError(err /*, response*/ ) { return err && _.includes(RETRIABLE_ERRORS, err.code); } NetworkError.RETRIABLE_ERRORS = RETRIABLE_ERRORS; module.exports = NetworkError; |