Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Add connect-domain to trap any unexpected error.
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffano committed Oct 15, 2014
1 parent 7b46df1 commit fbeb9a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
### 0.1.2-pre
* Set min node engine to >= v0.10.0
* Add connect-domain to trap any unexpected error

### 0.1.1
* Upgrade to express 4
Expand Down
22 changes: 15 additions & 7 deletions lib/ute.js
@@ -1,10 +1,11 @@
var ejs = require('ejs');
var express = require('express');
var partials = require('express-partials');
var fs = require('fs');
var nconf = require('nconf');
var p = require('path');
var util = require('util');
var connectDomain = require('connect-domain');
var ejs = require('ejs');
var express = require('express');
var partials = require('express-partials');
var fs = require('fs');
var nconf = require('nconf');
var p = require('path');
var util = require('util');

/**
* class Ute
Expand Down Expand Up @@ -52,6 +53,13 @@ Ute.prototype.start = function (handlers, opts) {
app[route.method.toLowerCase()](route.path, handlers[route.handler]);
});

// trap error
app.use(connectDomain());
app.use(function (err, req, res, next) {
console.error('An unexpected error occurred %s', err.message);
res.status(500).send(err.message);
});

// start the app
console.log('Starting application %s on port %d', nconf.get('app:name'), nconf.get('app:port'));
app.listen(nconf.get('app:port'));
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -24,8 +24,9 @@
"test": "./test"
},
"dependencies": {
"connect-domain": "~0.5.0",
"ejs": "~1.0.0",
"express": "~4.9.0",
"express": "~4.9.7",
"express-partials": "~0.3.0",
"nconf": "~0.6.9"
},
Expand Down

0 comments on commit fbeb9a6

Please sign in to comment.