Takes an error object and renders the login
form with that error.

@method

@param {Object} req - The http request.
@param {Object} res - The http response.
@param {Object} config - Stormpath config.
@param {Object} err - The error to display.
494677
function renderLoginFormWithError(req, res, config, err) {
  var logger = req.app.get('stormpathLogger');
  var view = config.web.login.view;
  var nextUri = url.parse(req.query.next || '').path;
  var encodedNextUri = encodeURIComponent(nextUri);
  var formActionUri = config.web.login.uri + (nextUri ? ('?next=' + encodedNextUri) : '');
  var oauthStateToken = common.resolveStateToken(req, res);

  var providers = buildProviderModel(req, res);

  var hasSocialProviders = !!Object.keys(config.web.social || {}).length;

  // Stormpath is unable to create or update the account because the
  // Facebook or Google response did not contain the required property.
  if (err.code === 7201) {
    logger.info('Provider login error: ' + err.message);
    err.userMessage = 'Login failed, because we could not retrieve your email address from the provider.  Please ensure that you have granted email permission to our application.';
  }

  getFormViewModel('login', config, function (err2, viewModel) {

    err = err2 || err;

    var options = {
      form: forms.loginForm,
      formActionUri: formActionUri,
      oauthStateToken: oauthStateToken,
      hasSocialProviders: hasSocialProviders,
      socialProviders: providers,
      error: err.userMessage || err.message,
      formModel: viewModel.form
    };

    render(req, res, view, options);
  });
}
994058
function onResError (ctx, err) {
  // nothing we can do here other
  // than delegate to the app-level
  // handler and log.
  if (ctx.headerSent || ctx._finished != null) {
    err.headerSent = ctx.headerSent
    err.context = ctx.toJSON()
    return err
  }

  // unset headers
  if (isFn(ctx.res.getHeaderNames)) {
    for (let name of ctx.res.getHeaderNames()) {
      if (!ON_ERROR_HEADER_REG.test(name)) ctx.res.removeHeader(name)
    }
  } else { // Node < 7.7
    let _headers = ctx.res._headers
    if (_headers) {
      // retain headers on error
      for (let name of Object.keys(_headers)) {
        if (!ON_ERROR_HEADER_REG.test(name)) delete _headers[name]
      }
    }
  }
  // support ENOENT to 404, default to 500
  if (err.code === 'ENOENT') ctx.status = 404
  else if (typeof err.status !== 'number' || !statuses[err.status]) ctx.status = 500
  else ctx.status = err.status

  ctx.set('x-content-type-options', 'nosniff')
  // support JSON error object: { error: 'BadRequest', message: 'Some bad request' }
  ctx.body = !isError(err) ? err : {
    error: err.error || err.name,
    message: err.expose ? err.message : statuses[ctx.status]
  }
  respond.call(ctx)
  return err
}
1069115
public function renderError($httpRequest, $errno, $errstr, $errfile, $errline)
    {
        if (!isset(self::$error_types[$errno])) {
            $errorTypeTitle = "UNKNOWN TYPE, ERRNO $errno";
        } else {
            $errorTypeTitle = self::$error_types[$errno]['title'];
        }
        $output = CLI::text("ERROR [" . $errorTypeTitle . "]: $errstr\nIN $httpRequest\n", "red", null, true);
        $output .= CLI::text("Line $errline in $errfile\n\n", "red");

        return $output;
    }
568886
def err_response(reqid, code, msg, data=None):
    
    err = { "code": code, "message": msg }
    if data:
        err["data"] = data
    return { "jsonrpc": "2.0", "id": reqid, "error": err }
1288116
function throwError(res, errorCode) {
    const error = decodeError(errorCode);
    res.writeHead(error.status, { 'Content-Type': 'application/json' });
    res.write(JSON.stringify(error));
    res.end();
}
604096
function(err, res) {
	      console.log(err);
	      res.reply(mInstance.conf.CONST.ERR);
	      return;
	    }
1223076
function (err, req, res, next) {

			if (seminarjs.get('logger')) {
				if (err instanceof Error) {
					console.log((err.type ? err.type + ' ' : '') + 'Error thrown for request: ' + req.url);
				} else {
					console.log('Error thrown for request: ' + req.url);
				}
				console.log(err.stack || err);
			}

			var msg = '';

			if (seminarjs.get('env') === 'development') {

				if (err instanceof Error) {
					if (err.type) {
						msg += '<h2>' + err.type + '</h2>';
					}
					msg += utils.textToHTML(err.message);
				} else if ('object' === typeof err) {
					msg += '<code>' + JSON.stringify(err) + '</code>';
				} else if (err) {
					msg += err;
				}
			}

			res.status(500).send(seminarjs.wrapHTMLError('Sorry, an error occurred loading the page (500)', msg));
		}
1010907
function serverError(err, res) {
  // error is required to be logged
  log('error', err.message, { stack: err.stack });

  const message = err.message || 'Server Error', // completely hide these messages from outside
    code = 500;

  sendDefaultResponseForCode(code, message, res);
}
562673
function(err, req, res, next) {
    err.message = err.message || 'Internal Server Error';
    err.code = err.code || res.code || 500;
    if (!_.isNumber(err.code)) {
      err.code = 500;
    }

    try {
      err.line = err.stack.split('\n')[1].match(/\(.+\)/)[0];
    } catch (e) {
      err.line = null;
    }

    var envelope = {
      meta: {
        code: err.code,
        error: {
          code: err.code,
          message: err.message,
          line: err.line
        }
      },
      data: err.message
    };

    // Set code and data
    res.code = err.code;
    res.data = envelope;

    return next();
  }
1110433
function _errorOnCall(config, err) {
    const errorResult = manageResponseErrors(err, config);
    _dispatchFieldErrors(config, errorResult.fields);
}
907316
function errorPage(res, errMsg, publicMsg, useLayout) {
	if ( useLayout === undefined ) useLayout = true;
	console.log(errMsg);
	res.render('error', {
		layout: useLayout,
		errMsg: errMsg,
		publicMsg: publicMsg
	});			
}
140575
function KboxRequireError(id, err) {
  Error.call(this);
  this.message = [id, err.message].join(' -> ');
  this.stack = [this.message, err.stack].join('\n');
}
1141619
function logResponse(err, res) {
    if (err || (res && !res.ok)) {
      if (err) {
        log.warn('%s on response -> read plaintext body due an error (%s)', app.name, err.message);
      } else {
        log.warn('%s on response -> read plaintext body due an error (%s)', app.name, res.error);
      }
    } else if (res && !_.isEmpty(res.body)) {
      if  (res.body[my.config.encryptedBodyName]) {
        log.info('%s on response -> read encrypted body', app.name);
      } else {
        log.info('%s on response -> read plaintext body', app.name);
      }
    }
  }
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);
                }
117490
function(err) {

        var message = 'Error occured while performing a JSON-WSP request. ' +
            err.message + '\n' +
            JSON.stringify({
                options : curOpts
            }, null, '  ').yellow;

        logger.error(message);
    }
568124
private String getCustomReloginErrorPage(HttpServletRequest req) {
        String reLogin = CookieHelper.getCookieValue(req.getCookies(), ReferrerURLCookieHandler.CUSTOM_RELOGIN_URL_COOKIENAME);
        if (reLogin != null && reLogin.length() > 0) {
            if (reLogin.indexOf("?") < 0)
                reLogin += "?error=error";
        }
        return reLogin;
    }
797732
function errors() {
        // handling 404 errors from config.express['404_redirect'] property
        if (config['404_redirect']) {
            server.use(function (req, res, next) {
                res.status(302)
                res.writeHead(302, { 'Location': config['404_redirect'] })
                res.end()
            })
        } else {
            server.use(function (req, res, next) {
                res.status(404).send({ message: 'not found' })
            })
        }

        if (errorHandlers.length) {
            for (let eh of errorHandlers) {
                server.use(wrapper(eh))
            }
        }

        //Default error handler
        server.use((err, req, res, next) => {
            if (!config.silent && !errorHandlers.length)
                app.drivers.logger.error('Unhandled server error', err)
            res.status(500)
               .json({
                   message: err.message,
                   stack: process.env.NODE_ENV === 'production' ? undefined : err.stack
               })
        })
    }