remove .outputErrors, suppress output when handled by the dev. Closes #272
This commit is contained in:
parent
4ff54e5c13
commit
f17629d19f
3 changed files with 11 additions and 4 deletions
|
@ -79,7 +79,6 @@ app.listen(3000);
|
||||||
- `app.env` defaulting to the __NODE_ENV__ or "development"
|
- `app.env` defaulting to the __NODE_ENV__ or "development"
|
||||||
- `app.proxy` when true proxy header fields will be trusted
|
- `app.proxy` when true proxy header fields will be trusted
|
||||||
- `app.subdomainOffset` offset of `.subdomains` to ignore [2]
|
- `app.subdomainOffset` offset of `.subdomains` to ignore [2]
|
||||||
- `app.outputErrors` output err.stack to stderr [false in "test" environment]
|
|
||||||
|
|
||||||
## app.listen(...)
|
## app.listen(...)
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ app.listen = function(){
|
||||||
|
|
||||||
app.toJSON = function(){
|
app.toJSON = function(){
|
||||||
return only(this, [
|
return only(this, [
|
||||||
'outputErrors',
|
|
||||||
'subdomainOffset',
|
'subdomainOffset',
|
||||||
'poweredBy',
|
'poweredBy',
|
||||||
'env'
|
'env'
|
||||||
|
@ -156,8 +155,18 @@ app.createContext = function(req, res){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
app.onerror = function(err){
|
app.onerror = function(err){
|
||||||
if (!this.outputErrors) return;
|
if (!err) return;
|
||||||
|
|
||||||
|
// suppress output for custom handling
|
||||||
|
if (1 != this.listeners('error').length) return;
|
||||||
|
|
||||||
|
// ignore 404s
|
||||||
if (404 == err.status) return;
|
if (404 == err.status) return;
|
||||||
|
|
||||||
|
// ignore in test env
|
||||||
|
if ('test' == this.env) return;
|
||||||
|
|
||||||
|
// output
|
||||||
console.error();
|
console.error();
|
||||||
console.error(err.stack.replace(/^/gm, ' '));
|
console.error(err.stack.replace(/^/gm, ' '));
|
||||||
console.error();
|
console.error();
|
||||||
|
|
|
@ -53,7 +53,6 @@ describe('app.toJSON()', function(){
|
||||||
var obj = app.toJSON();
|
var obj = app.toJSON();
|
||||||
|
|
||||||
obj.should.eql({
|
obj.should.eql({
|
||||||
outputErrors: false,
|
|
||||||
subdomainOffset: 2,
|
subdomainOffset: 2,
|
||||||
poweredBy: true,
|
poweredBy: true,
|
||||||
env: 'test'
|
env: 'test'
|
||||||
|
|
Loading…
Reference in a new issue