Skip to content

Commit

Permalink
Added RayGun to track errors
Browse files Browse the repository at this point in the history
LGTMs Jon
  • Loading branch information
jonstorer committed Jan 24, 2014
1 parent 3fd5cf4 commit 9fd3e4c
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 481 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.10.15
v0.10.24
3 changes: 2 additions & 1 deletion config/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ express = require 'express'
flash = require 'connect-flash'
path = require('path')

module.exports = (app) ->
module.exports = (app, next) ->
app.configure ->
app.set 'views', path.join(__dirname, '..', 'views')
app.set 'view engine', 'ejs'
Expand All @@ -18,3 +18,4 @@ module.exports = (app) ->
app.use passport.session()
app.use app.router
app.use express.static path.join(__dirname, '..', 'public')
next(app)
11 changes: 7 additions & 4 deletions config/environments/development.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
application = require('../application')
application = require '../application'
express = require 'express'

module.exports = (app) ->
app.use express.logger('dev')
application app
app.configure 'development', ->
app.use express.errorHandler()
application app, (app) ->
app.configure 'development', ->
app.use (req, res, next) ->
res.send('Page not found', 404)
app.use (error, req, res, next) ->
res.send('500: Internal Server Error', 500)
11 changes: 10 additions & 1 deletion config/environments/production.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
application = require('../application')
express = require 'express'
raygun = require('raygun')
Raygun = new raygun.Client().init({ apiKey: 'SBuL7PyTCi3Qgx2UkUqgGA==' })

module.exports = (app) ->
app.configure ->
application app, (app) ->
app.configure 'production', ->
app.use express.errorHandler()

app.use (req, res, next) ->
Raygun.send new Error("404 @ #{req.url}")
res.send(404, '404: Page not found')

app.use (error, req, res, next) ->
Raygun.send error
res.send(500, '500: Internal Server Error')
32 changes: 19 additions & 13 deletions config/environments/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ User = require '../../models/user'

module.exports = (app) ->
app.use express.logger('dev')
application app
app.configure 'test', ->
app.use express.errorHandler()
app.get '/login_for_test/:id', (req, res) ->
id = req.route.params.id
User.findById id, (err, user) ->
console.log err if err
req.login user, (err) ->
if err
console.log err
res.send(500, { error: 'could not log in' })
else
res.json 200, user
application app, (app) ->
app.configure 'test', ->
app.use express.errorHandler()
app.get '/login_for_test/:id', (req, res) ->
id = req.route.params.id
User.findById id, (err, user) ->
console.log err if err
req.login user, (err) ->
if err
console.log err
res.send(500, { error: 'could not log in' })
else
res.json 200, user

app.use (req, res, next) ->
res.send('Page not found', 404)

app.use (error, req, res, next) ->
res.send('500: Internal Server Error', 500)
Loading

0 comments on commit 9fd3e4c

Please sign in to comment.