app.silent option to turn off err logging

This commit is contained in:
Tejas Manohar 2015-10-05 17:51:26 -05:00
parent b2bcbcec7c
commit c369b33b23
2 changed files with 3 additions and 2 deletions

View File

@ -165,7 +165,7 @@ app.onerror = function(err){
assert(err instanceof Error, 'non-error thrown: ' + err); assert(err instanceof Error, 'non-error thrown: ' + err);
if (404 == err.status || err.expose) return; if (404 == err.status || err.expose) return;
if ('test' == this.env) return; if (this.silent) return;
var msg = err.stack || err.toString(); var msg = err.stack || err.toString();
console.error(); console.error();

View File

@ -161,8 +161,9 @@ describe('app.onerror(err)', function(){
done(); done();
}) })
it('should do nothing if env is test', function(done){ it('should do nothing if .silent', function(done){
var app = koa(); var app = koa();
app.silent = true;
var err = new Error(); var err = new Error();
var output = stderr.inspectSync(function() { var output = stderr.inspectSync(function() {