src/index.js
function catchClientError(req, res, next) {
  const { end } = res;

  res.end = function() {
    // console.log(`Catch client response : ${req.url} ${res.statusCode}`);
    const errorRoute = Route
      .routes('err')
      .filter((obj) => {
        return obj.extra.status === res.statusCode && obj.route !== req.url;
      });

    if(errorRoute.length > 0 && !isRedirect) {
      return redirect(errorRoute[0], req, res, next);
    }

    isRedirect = false;
    end.apply(res, arguments);
  };

  next();
}
function catchClientError(req, res, next) {
  const { end } = res;

  res.end = function() {
    // console.log(`Catch client response : ${req.url} ${res.statusCode}`);
    const errorRoute = Route
      .routes('err')
      .filter((obj) => {
        return obj.extra.status === res.statusCode && obj.route !== req.url;
      });

    if(errorRoute.length > 0 && !isRedirect) {
      return redirect(errorRoute[0], req, res, next);
    }

    isRedirect = false;
    end.apply(res, arguments);
  };

  next();
}
function catchClientError ( req , res , next ) { const { end } = res ; res . end = function ( ) { // console.log(`Catch client response : ${req.url} ${res.statusCode}`); const errorRoute = Route . routes ( 'err' ) . filter ( ( obj ) => { return obj . extra . status === res . statusCode && obj . route !== req . url ; } ) ; if ( errorRoute . length > 0 && ! isRedirect ) { return redirect ( errorRoute [ 0 ] , req , res , next ) ; } isRedirect = false ; end . apply ( res , arguments ) ; } ; next ( ) ; }
Catch client response for redirect to error
@param req
@param res
@param next
Catch client response for redirect to error