All files / node-activedirectory/lib/services/internal/search service.search.onClientError.js

16.67% Statements 2/12
0% Branches 0/14
0% Functions 0/2
16.67% Lines 2/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 441x                                                                                     1x
const log           = require('../service.log');
/**
 * Occurs when a client / search error occurs.
 * @param {Object} err The error object or string.
 * @param {Object} client The LDAP Client
 * @param {Date} searchStarted The Date when the search was initiated
 * @param {String} baseDN
 * @param {Object} opts Options
 * @param {Function} resolve Resolve the search request
 * @param {Function} reject reject the search request
 * @param {Object} res The optional server response.
 * 
 * @returns {void}
 */
 
function onClientError(err, client, searchStarted, baseDN, opts, results, resolve, reject) {
    // let ignoreError = false;
    
    if ((err || {}).name === 'SizeLimitExceededError') {
        onSearchEnd(client, baseDN, opts, results, resolve, reject);
        return;
    }
 
    if((err || {}).errno === 'ETIMEDOUT'){
        err.timeoutAfter = (new Date() - searchStarted);
    }
    // Ignore ECONNRESET Errors from client
    if((err || {}).errno ==='ECONNRESET'){
        // ignoreError = true;
    }
    if(client.connected) {
        client.unbind(() => {
            // log.error(err, '[%s] An error occurred performing the requested LDAP search on %s (%j)',
            //     (err || {}).errno || 'UNKNOWN', baseDN, opts);
                return reject(err);
        });
    } else {
        return reject(err);
    }
    
    
}
 
module.exports = onClientError;