function errorListener(client, name, reject) {
  const fn = function (err) {
    if (eventHandled(client)) {
      // error already handled or expected - ignore
      client.debugMsg(`${name} errorListener - ignoring handled error ${err.message}`);
      return;
    }
    client.debugMsg(`${name} errorListener - handling error ${err.message}`);
    client.errorHandled = true;
    const newError = new Error(`${name}: ${err.message}`);
    newError.code = err.code;
    if (reject) {
      reject(newError);
    } else {
      throw newError;
    }
  };
  return fn;
}
Simple default error listener. Will reformat the error message and
throw a new error.

@param {Error} err - source for defining new error
@throws {Error} Throws new error