lib/source-map-support.js
function handleUncaughtExceptions(error) {
  if (!error || !error.stack) {
    console.log('Uncaught exception:', error);
    process.exit();
  }
  var match = /\n    at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
  if (match) {
    var cache = {};
    var position = mapSourcePosition(cache, {
      source: match[1],
      line: match[2],
      column: match[3]
    });
    if (fs.existsSync(position.source)) {
      var contents = fs.readFileSync(position.source, 'utf8');
      var line = contents.split(/(?:\r\n|\r|\n)/)[position.line - 1];
      if (line) {
        console.log('\n' + position.source + ':' + position.line);
        console.log(line);
        console.log(new Array(+position.column).join(' ') + '^');
      }
    }
  }
  console.log(error.stack);
  process.exit();
}
function handleUncaughtExceptions(error) {
  if (!error || !error.stack) {
    console.log('Uncaught exception:', error);
    process.exit();
  }
  var match = /\n    at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
  if (match) {
    var cache = {};
    var position = mapSourcePosition(cache, {
      source: match[1],
      line: match[2],
      column: match[3]
    });
    if (fs.existsSync(position.source)) {
      var contents = fs.readFileSync(position.source, 'utf8');
      var line = contents.split(/(?:\r\n|\r|\n)/)[position.line - 1];
      if (line) {
        console.log('\n' + position.source + ':' + position.line);
        console.log(line);
        console.log(new Array(+position.column).join(' ') + '^');
      }
    }
  }
  console.log(error.stack);
  process.exit();
}
function handleUncaughtExceptions ( error ) { if ( ! error || ! error . stack ) { console . log ( 'Uncaught exception:' , error ) ; process . exit ( ) ; } var match = / \n    at [^(]+ \((.*):(\d+):(\d+)\) / . exec ( error . stack ) ; if ( match ) { var cache = { } ; var position = mapSourcePosition ( cache , { source : match [ 1 ] , line : match [ 2 ] , column : match [ 3 ] } ) ; if ( fs . existsSync ( position . source ) ) { var contents = fs . readFileSync ( position . source , 'utf8' ) ; var line = contents . split ( / (?:\r\n|\r|\n) / ) [ position . line - 1 ] ; if ( line ) { console . log ( '\n' + position . source + ':' + position . line ) ; console . log ( line ) ; console . log ( new Array ( + position . column ) . join ( ' ' ) + '^' ) ; } } } console . log ( error . stack ) ; process . exit ( ) ; }
Mimic node's stack trace printing when an exception escapes the process
Mimic node s stack trace printing when an exception escapes the process