src/mongo/shell/utils.js
/**
 * Determine if a provided object represents a network error
 * @param {object|Error|string|number} errorOrResponse A command response, error or scalar
 *     representing an error
 */
Determine if a provided object represents a network error
@param {object|Error|string|number} errorOrResponse A command response, error or scalar
representing an error
Determine if a provided object represents a network error @param { object|Error|string|number } errorOrResponse A command response error or scalar representing an error
function isNetworkError(errorOrResponse) {
    if (errorOrResponse.code) {
        if (ErrorCodes.isNetworkError(errorOrResponse.code)) {
            return true;
        }
    }
    if (errorOrResponse.message) {
        if (networkErrsPlusShellGeneratedNetworkErrs.some(
                err => errorOrResponse.message.includes(err))) {
            return true;
        }
    }
    return ErrorCodes.isNetworkError(errorOrResponse);
}
function isNetworkError ( errorOrResponse ) { if ( errorOrResponse . code ) { if ( ErrorCodes . isNetworkError ( errorOrResponse . code ) ) { return true ; } } if ( errorOrResponse . message ) { if ( networkErrsPlusShellGeneratedNetworkErrs . some ( err => errorOrResponse . message . includes ( err ) ) ) { return true ; } } return ErrorCodes . isNetworkError ( errorOrResponse ) ; }
Determine if a provided object represents a network error
 @param {object|Error|string|number} errorOrResponse A command response, error or scalar
     representing an error
Determine if a provided object represents a network error @param { object|Error|string|number } errorOrResponse A command response error or scalar representing an error
// First check if this is a command response, if so check by error code // Then check if it's an Error, if so see if any of the known network error strings appear // in the given message. // Otherwise fall back to checking by scalar value