src/utils.js
/**
 * Tests an error to see if it is one which has already been customised
 * by this module or not. If not, applies appropriate customisation.
 *
 * @param {Error} err - an Error object
 * @param {String} name - name to be used in customised error message
 * @param {Function} reject - If defined, call this function instead of
 *                            throwing the error
 * @throws {Error}
 */
Tests an error to see if it is one which has already been customised
by this module or not. If not, applies appropriate customisation.

@param {Error} err - an Error object
@param {String} name - name to be used in customised error message
@param {Function} reject - If defined, call this function instead of
throwing the error
@throws {Error}
Tests an error to see if it is one which has already been customised by this module or not . If not applies appropriate customisation . @param { Error } err - an Error object @param { String } name - name to be used in customised error message @param { Function } reject - If defined call this function instead of throwing the error @throws { Error }
function handleError(err, name, reject) {
  if (reject) {
    if (err.custom) {
      reject(err);
    } else {
      reject(formatError(err, name));
    }
  } else {
    if (err.custom) {
      throw err;
    } else {
      throw formatError(err, name);
    }
  }
}
function handleError ( err , name , reject ) { if ( reject ) { if ( err . custom ) { reject ( err ) ; } else { reject ( formatError ( err , name ) ) ; } } else { if ( err . custom ) { throw err ; } else { throw formatError ( err , name ) ; } } }
Tests an error to see if it is one which has already been customised
 by this module or not.
Tests an error to see if it is one which has already been customised by this module or not .