lib/handlers/error.js
function (err, req, res, next) {
    err = this.coerceError(err);

    if (err instanceof errors.NotFound && req.accepts('html')) {
      if (err instanceof errors.BinNotFound) {
        if (req.editor) {
          return (new BinHandler(this.sandbox)).notFound(req, res, next);
        }
      }

      return this.renderErrorPage('error', err, req, res);
    } else if (err instanceof errors.HTTPError) {
      // return this.renderError(err, req, res);
      return this.renderErrorPage(err.status, err, req, res);
    }

    if (err) {
      // console.error(err.stack);
    }

    next(err);
  }
function (err, req, res, next) {
    err = this.coerceError(err);

    if (err instanceof errors.NotFound && req.accepts('html')) {
      if (err instanceof errors.BinNotFound) {
        if (req.editor) {
          return (new BinHandler(this.sandbox)).notFound(req, res, next);
        }
      }

      return this.renderErrorPage('error', err, req, res);
    } else if (err instanceof errors.HTTPError) {
      // return this.renderError(err, req, res);
      return this.renderErrorPage(err.status, err, req, res);
    }

    if (err) {
      // console.error(err.stack);
    }

    next(err);
  }
function ( err , req , res , next ) { err = this . coerceError ( err ) ; if ( err instanceof errors . NotFound && req . accepts ( 'html' ) ) { if ( err instanceof errors . BinNotFound ) { if ( req . editor ) { return ( new BinHandler ( this . sandbox ) ) . notFound ( req , res , next ) ; } } return this . renderErrorPage ( 'error' , err , req , res ) ; } else if ( err instanceof errors . HTTPError ) { // return this.renderError(err, req, res); return this . renderErrorPage ( err . status , err , req , res ) ; } if ( err ) { // console.error(err.stack); } next ( err ) ; }
Handles all types of HTTPError and ensures that the correct type of response is returned depending on the type of content requested. So if you're expecting JSON you should get JSON.
Handles all types of HTTPError and ensures that the correct type of response is returned depending on the type of content requested . So if you re expecting JSON you should get JSON .