mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Handle sentry config and express routing/page handling errors, to do: handle uncaughtExceptions
This commit is contained in:
parent
713317cb09
commit
b33645beda
2 changed files with 17 additions and 1 deletions
|
@ -28,7 +28,8 @@
|
||||||
"express-http-proxy": "0.6.0",
|
"express-http-proxy": "0.6.0",
|
||||||
"lodash.defaults": "3.1.2",
|
"lodash.defaults": "3.1.2",
|
||||||
"mustache": "2.1.3",
|
"mustache": "2.1.3",
|
||||||
"newrelic": "1.22.1"
|
"newrelic": "1.22.1",
|
||||||
|
"raven": "0.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer-loader": "2.1.0",
|
"autoprefixer-loader": "2.1.0",
|
||||||
|
|
|
@ -33,6 +33,21 @@ for (var routeId in routes) {
|
||||||
app.get(route.pattern, handler(route));
|
app.get(route.pattern, handler(route));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof process.env.SENTRY_DSN === 'string' ) {
|
||||||
|
var raven = require('raven');
|
||||||
|
app.get( '/sentrythrow', function mainHandler (req,res) { throw new Error('Sentry Test'); } );
|
||||||
|
|
||||||
|
// These handlers must be applied _AFTER_ other rotes have been applied
|
||||||
|
app.use( raven.middleware.express.requestHandler( process.env.SENTRY_DSN ) );
|
||||||
|
app.use( raven.middleware.express.errorHandler( process.env.SENTRY_DSN ) );
|
||||||
|
app.use( function errorHandler(err, req, res, next) {
|
||||||
|
res.append('X-Sentry-ID:'+res.sentry);
|
||||||
|
res.status(500);
|
||||||
|
next(err);
|
||||||
|
} );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Bind proxies in development
|
// Bind proxies in development
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
var proxyHost = process.env.PROXY_HOST || 'https://staging.scratch.mit.edu';
|
var proxyHost = process.env.PROXY_HOST || 'https://staging.scratch.mit.edu';
|
||||||
|
|
Loading…
Reference in a new issue