"post" hook Error handling
@param {*} err the error returned by latest "post" hook
504183
function postHookErrorHandler(err) {
                    /**
                     * Helper to add an error to an Object "errors" Symbol
                     */
                    const addError = (obj) => {
                        obj[ERR_KEY] = obj[ERR_KEY] || [];
                        obj[ERR_KEY].push(err);
                        return obj;
                    };

                    /**
                     * For response type that are *not* objects (string, integers, functions...)
                     * we convert the response to an object with a "result" property and set it as "override"
                     */
                    if (typeof response !== 'object') {
                        response = {
                            __override: {
                                result: response,
                            },
                        };
                    }

                    if ({}.hasOwnProperty.call(response, '__override')) {
                        response.__override = addError(response.__override);
                    } else {
                        response = addError(response);
                    }

                    return nextPostHook(response);
                }
206333
function err(...messages) {
  console.error(...messages);
  const p = document.createElement('p');
  p.innerText = messages.join(' ');
  p.style = 'color: red';
  logElement.appendChild(p);
}
643667
function errorHandler(err, req, res, next) {
  req.error = err;
  const errorHandlers = Route.routes('handler').filter((obj) => {
    return obj.target === req.url;
  });

  if(errorHandlers.length > 0) {
    return redirect(errorHandlers[0], req, res, next);
  }


  const errorRoute = Route.routes('err').filter((obj) => {
    return obj.extra.status === 500;
  });

  if(isDebug) {
    console.log(err.message);
  }

  if(errorRoute.length > 0) {
    return redirect(errorRoute[0], req, res, next, err);
  } else {
    app.set('view engine', 'ejs');
    res.status(500).render(`${__dirname}/src/assets/errors.ejs`, {
      status: 500,
      message: err.message
    });
  }
}
182493
function errorHandler(response) {
        if (response) {
          var errorData = _buildError(xhr, url, method, response);
          Logger.error(errorData);

          if (errorCallback) {
            Logger.warnCallbackDeprecation();
            errorCallback(errorData);
          }
          reject(errorData);
        }
      }
1114436
function (err) {
                var responseOptions = new ResponseOptions({
                    body: err,
                    type: ResponseType.Error,
                    status: _xhr.status,
                    statusText: _xhr.statusText,
                });
                if (baseResponseOptions != null) {
                    responseOptions = baseResponseOptions.merge(responseOptions);
                }
                responseObserver.error(new Response(responseOptions));
            }
705740
function(err) {
		/**
		 * If err is an Error object, break the chain and call catch
		 */
		if (err && (err.constructor.name === "Error" || err.constructor.name === "TypeError") && this.onCatch) {
			this.onCatch(err);
			return;
		}

		var nextFn = this.fnStack.shift();
		if (nextFn) {
			/**
			 * Ensure arguments are passed as an Array
			 */
			var args = Array.prototype.slice.call(arguments);
			return this.execute(nextFn.fn, args);
		}
	}
494097
function onOutError(err) {
    errNodecat = combineErrors(errNodecat, err);
    errStream.write(`nodecat: ${err}\n`);
    if (inCleanup) {
      inCleanup();
    }
    allDone();
  }
1083429
function proxyError(err) {
    errState = true;

    //
    // Emit an `error` event, allowing the application to use custom
    // error handling. The error handler should end the response.
    //
    if (self.emit('proxyError', err, req, res)) {
      return;
    }

    res.writeHead(500, { 'Content-Type': 'text/plain' });

    if (req.method !== 'HEAD') {
      //
      // This NODE_ENV=production behavior is mimics Express and
      // Connect.
      //
      if (process.env.NODE_ENV === 'production') {
        res.write('Internal Server Error');
      }
      else {
        res.write('An error has occurred: ' + JSON.stringify(err));
      }
    }

    try { res.end() }
    catch (ex) { console.error("res.end error: %s", ex.message) }
  }
1301320
function(err) {
    notify.onError({
        title: "Error: " + err.plugin,
        subtitle: "<%= file.relative %>",
        message: "<%= error.message %>",
        sound: "Beep",
    })(err);
    console.log(err.toString())
    this.emit('end');
}
668027
function(err) {
            Dialogs.alert("Error:", err.message || err);
            console.error(err.stack || err.message || err);
            return Q.reject(err);
        }
75133
function error(err, req, res, next) {
  // log it
  if (!test) console.error(err.stack);

  // respond with 500 "Internal Server Error".
  res.status(500);
  res.send('Internal Server Error');
}
166015
async function onerror(err) {
  // don't do anything if there is no error.
  // this allows you to pass `this.onerror`
  // to node-style callbacks.
  if (null == err) return;

  if (!(err instanceof Error))
    err = new Error(format("non-error thrown: %j", err));

  let headerSent = false;
  if (this.headerSent || !this.writable) {
    headerSent = err.headerSent = true;
  }

  // delegate
  this.app.emit("error", err, this);

  // nothing we can do here other
  // than delegate to the app-level
  // handler and log.
  if (headerSent) {
    return;
  }

  const { res } = this;

  if (!(err instanceof S3Error)) {
    err = S3Error.fromError(err);
  }

  // first unset all headers
  res
    .getHeaderNames()
    .filter(name => !name.match(/^access-control-|vary|x-amz-/i))
    .forEach(name => res.removeHeader(name));

  // (the presence of x-amz-error-* headers needs additional research)
  // this.set(err.headers);

  // force text/html
  this.type = "text/html";

  if (!err.description)
    err.description = `${err.status} ${statuses[err.status]}`;

  // respond
  const { website } = this.state;
  if (
    err.code !== "NoSuchBucket" &&
    err.code !== "UnsupportedQuery" &&
    website.errorDocumentKey
  ) {
    // attempt to serve error document
    const object = await this.store.getObject(
      this.params.bucket,
      website.errorDocumentKey
    );
    if (object) {
      const objectRedirectLocation =
        object.metadata["x-amz-website-redirect-location"];
      if (objectRedirectLocation) {
        object.content.destroy();
        this.status = 301;
        this.redirect(objectRedirectLocation);
        res.end(this.body);
      } else {
        this.type = object.metadata["content-type"];
        this.length = object.size;
        object.content.pipe(res);
      }
      return;
    }
    this.logger.error(
      "Custom Error Document not found: " + website.errorDocumentKey
    );
    const errorDocumentErr = new S3Error(
      "NoSuchKey",
      "The specified key does not exist.",
      { Key: website.errorDocumentKey }
    );
    errorDocumentErr.description =
      "An Error Occurred While Attempting to Retrieve a Custom Error Document";
    err.errors.push(errorDocumentErr);
  }

  const msg = err.toHTML();
  this.status = err.status;
  this.length = Buffer.byteLength(msg);
  res.end(msg);
}
838606
function onError (err) {
  console.error(chalk.red('✗ error:'), chalk.red(err.message))
  notifier.notify({
    title: 'Build failed:',
    message: err.message
  })
  this.emit('end')

  // When running without watch, process.exit(1) on error
  if (!watchifyEnabled) {
    process.exit(1)
  }
}
1288116
function throwError(res, errorCode) {
    const error = decodeError(errorCode);
    res.writeHead(error.status, { 'Content-Type': 'application/json' });
    res.write(JSON.stringify(error));
    res.end();
}
1169982
function defaultErrorHandler(err, req, res) {
  if (err.name === 'UnauthorizedError') { // authentication is expected to be a common use-case
    res.status(401).end();
  } else {
    if (!err.status || err.status >= 500) {
      console.error(err.stack || err.toString());
    }
    res.status(err.status || 500).json({message: err.message})
  }
}
1174539
function onError(err) {
        if (callback) {
            callback(err);
        }
        else if (that.emitErrs) {
            that.emit('error', err);
        }
    }
258018
function errHandler(err) {
    process.stderr.write(chalk.red('Model generation failed!') + '\n');

    switch (err.code) {
      default:
        case 'PARSE_FAIL':
        if (!quiet) {
          process.stderr.write('\n' + err.stack + '\n');
        }
      break;

      case 'ENOENT':
          if (!quiet) {
            process.stderr.write('\n' + err.stack.replace('ENOENT, lstat ', 'unable to find ') + '\n');
          }
        break;
    }
    callback(err);
  }