index.js
function buildError(err, hackErr) {
  var stack1 = err.stack;
  var stack2 = hackErr.stack;
  var label = hackErr.label;

  var stack = [];

  stack1.split('\n').forEach(function(line, index, arr) {
    if (line.match(/^    at GeneratorFunctionPrototype.next/)) {
      stack = stack.concat(arr.slice(0, index));
      return;
    }
  });

  stack = stack.concat(stack2.split('\n').slice(2));
  if (!stack[0].match(/^Error:/)) {
    stack.unshift(err.message);
  }
  if (!!label) {
    stack.unshift('[DEBUG: ' + label + ']');
  }
  stack = stack.join('\n');

  var newError = new Error();
  newError.message = err.message;
  newError.stack = stack;

  return newError;
}
function buildError(err, hackErr) {
  var stack1 = err.stack;
  var stack2 = hackErr.stack;
  var label = hackErr.label;

  var stack = [];

  stack1.split('\n').forEach(function(line, index, arr) {
    if (line.match(/^    at GeneratorFunctionPrototype.next/)) {
      stack = stack.concat(arr.slice(0, index));
      return;
    }
  });

  stack = stack.concat(stack2.split('\n').slice(2));
  if (!stack[0].match(/^Error:/)) {
    stack.unshift(err.message);
  }
  if (!!label) {
    stack.unshift('[DEBUG: ' + label + ']');
  }
  stack = stack.join('\n');

  var newError = new Error();
  newError.message = err.message;
  newError.stack = stack;

  return newError;
}
function buildError ( err , hackErr ) { var stack1 = err . stack ; var stack2 = hackErr . stack ; var label = hackErr . label ; var stack = [ ] ; stack1 . split ( '\n' ) . forEach ( function ( line , index , arr ) { if ( line . match ( / ^    at GeneratorFunctionPrototype.next / ) ) { stack = stack . concat ( arr . slice ( 0 , index ) ) ; return ; } } ) ; stack = stack . concat ( stack2 . split ( '\n' ) . slice ( 2 ) ) ; if ( ! stack [ 0 ] . match ( / ^Error: / ) ) { stack . unshift ( err . message ) ; } if ( ! ! label ) { stack . unshift ( '[DEBUG: ' + label + ']' ) ; } stack = stack . join ( '\n' ) ; var newError = new Error ( ) ; newError . message = err . message ; newError . stack = stack ; return newError ; }
Build the full error stack
Build the full error stack