Skip to content

Commit

Permalink
add uncaughtException fallack handler (fixes issue krakenjs#36) and r…
Browse files Browse the repository at this point in the history
…emove deps on winston
  • Loading branch information
totherik committed Aug 12, 2013
1 parent 0cb37a2 commit aa679a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

var Q = require('q'),
appcore = require('./lib/appcore');
appcore = require('./lib/appcore'),
EventEmitter = require('events').EventEmitter;


var webcore = {
Expand Down Expand Up @@ -96,7 +97,19 @@ var webcore = {
return deferred.promise;
}

function handleErrors(app) {
if (!EventEmitter.listenerCount(process, 'uncaughtException')) {
process.on('uncaughtException', function (err) {
console.error(new Date().toUTCString(), 'uncaughtException', err.message);
console.error(err.stack);
process.exit(1);
});
}
return app;
}

return this._promise
.then(handleErrors)
.then(bind)
.nodeify(callback);
}
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"devDependencies": {
"mocha": "~1.9.0",
"chai": "~1.5.0",
"express-winston": "~0.2.0",
"consolidate": "~0.9.0",
"jade": "~0.29.0",
"less": "~1.3.3",
Expand All @@ -31,7 +30,6 @@
"grunt": "~0.4.1",
"grunt-ci-suite": "~0.1.2",
"grunt-contrib-clean": "~0.5.0",
"winston": "~0.7.1",
"nconf": "~0.6.7",
"dustjs-i18n": "~0.0.8"
},
Expand Down
1 change: 0 additions & 1 deletion test/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

var path = require('path'),
webcore = require('../index'),
winston = require('winston'),
assert = require('chai').assert;

describe.skip('middleware', function () {
Expand Down

0 comments on commit aa679a5

Please sign in to comment.