Exemplo n.º 1
0
function outputError (msg) {
  var fail = msg.fail;
  var error = {
    message: fail.name,
    stack: fail.stack
  };

  console.log(formatText(error.stack ? errorTemplate : errorNoStackTemplate, {
    browser: formatUserAgent(msg.userAgent),
    title: fail.test,
    diff: diff(fail),
    error: nodeReporter.tab(prettifyError(error, undefined, fail.source) || '', '    ')
  }));
}
Exemplo n.º 2
0
Assert.add('test', function test(passed, msg, expectation, slice) {
  called++; // Needed for tracking the amount of executed assertions.

  if (this._not) passed = !passed;
  if (passed) return this;

  msg = msg || 'Unknown assertation failure occured';
  slice = slice || this.sliceStack;

  if (expectation) msg += ', assumed ' + expectation(this._not);

  var failure = new Error(msg)
    , err = { message: failure.message, stack: '' };

  if (this.stacktrace) {
    err.stack = failure.stack || err.stack;
  }

  //
  // Clean up the stack by slicing off the parts that are pointless to most
  // people. (Like where it enters this assertion library).
  //
  err.stack = err.stack.split('\n').slice(slice).join('\n') || err.stack;
  err.stack = pretty(err);

  if ('function' !== typeof Object.create) {
    if ('object' === typeof console && 'function' === typeof console.error) {
      console.error(err.stack);
    }

    throw failure;
  }

  failure = Object.create(Error.prototype);
  failure.message = err.message;
  failure.stack = err.stack;

  throw failure;
});
Exemplo n.º 3
0
process.on('uncaughtException', function (error) {
  console.error('\n', prettifyError(error) || error);
});
Exemplo n.º 4
0
 read.bundle({ debug: true }).on('error', function (error) {
   debug('Failed to browserify the source code. We\'re probably missing a module required. The error was:');
   process.stderr.write('\n    ');
   console.error(prettifyError(error, 0));
 }).pipe(write);