index.js
function rethrow(options) {
  var opts = lazy.extend({before: 3, after: 3}, options);
  return function (err, filename, lineno, str, expr) {
    if (!(err instanceof Error)) throw err;

    lineno = lineno >> 0;
    var lines = str.split('\n');
    var before = Math.max(lineno - (+opts.before), 0);
    var after = Math.min(lines.length, lineno + (+opts.after));

    // align line numbers
    var n = lazy.align(count(lines.length + 1));

    lineno++;
    var pointer = errorMessage(err, opts);

    // Error context
    var context = lines.slice(before, after).map(function (line, i) {
      var num = i + before + 1;
      var msg = style(num, lineno);

      return msg('  > ', '    ')
        + n[num] + '| '
        + line + ' ' + msg(expr, '');
    }).join('\n');

    // Alter exception message
    err.path = filename;
    err.message = (filename || 'source') + ':'
      + lineno + '\n'
      + context + '\n\n'
      + (pointer ? (pointer + lazy.yellow(filename)) : styleMessage(err.message, opts)) + '\n';

    throw err.message;
  };
}
function rethrow(options) {
  var opts = lazy.extend({before: 3, after: 3}, options);
  return function (err, filename, lineno, str, expr) {
    if (!(err instanceof Error)) throw err;

    lineno = lineno >> 0;
    var lines = str.split('\n');
    var before = Math.max(lineno - (+opts.before), 0);
    var after = Math.min(lines.length, lineno + (+opts.after));

    // align line numbers
    var n = lazy.align(count(lines.length + 1));

    lineno++;
    var pointer = errorMessage(err, opts);

    // Error context
    var context = lines.slice(before, after).map(function (line, i) {
      var num = i + before + 1;
      var msg = style(num, lineno);

      return msg('  > ', '    ')
        + n[num] + '| '
        + line + ' ' + msg(expr, '');
    }).join('\n');

    // Alter exception message
    err.path = filename;
    err.message = (filename || 'source') + ':'
      + lineno + '\n'
      + context + '\n\n'
      + (pointer ? (pointer + lazy.yellow(filename)) : styleMessage(err.message, opts)) + '\n';

    throw err.message;
  };
}
function rethrow ( options ) { var opts = lazy . extend ( { before : 3 , after : 3 } , options ) ; return function ( err , filename , lineno , str , expr ) { if ( ! ( err instanceof Error ) ) throw err ; lineno = lineno >> 0 ; var lines = str . split ( '\n' ) ; var before = Math . max ( lineno - ( + opts . before ) , 0 ) ; var after = Math . min ( lines . length , lineno + ( + opts . after ) ) ; // align line numbers var n = lazy . align ( count ( lines . length + 1 ) ) ; lineno ++ ; var pointer = errorMessage ( err , opts ) ; // Error context var context = lines . slice ( before , after ) . map ( function ( line , i ) { var num = i + before + 1 ; var msg = style ( num , lineno ) ; return msg ( '  > ' , '    ' ) + n [ num ] + '| ' + line + ' ' + msg ( expr , '' ) ; } ) . join ( '\n' ) ; // Alter exception message err . path = filename ; err . message = ( filename || 'source' ) + ':' + lineno + '\n' + context + '\n\n' + ( pointer ? ( pointer + lazy . yellow ( filename ) ) : styleMessage ( err . message , opts ) ) + '\n' ; throw err . message ; } ; }
Re-throw the given `err` in context to the offending
template expression in `filename` at the given `lineno`.

@param {Error} `err` Error object
@param {String} `filename` The file path of the template
@param {String} `lineno` The line number of the expression causing the error.
@param {String} `str` Template string
@api public
Re - throw the given err in context to the offending template expression in filename at the given lineno .