Refine error page to in all situations, and don't send sentry errors on not found errors

This commit is contained in:
James Allen 2016-03-21 11:55:59 +00:00
parent e7d67668e9
commit 2a9e451876
3 changed files with 26 additions and 20 deletions

View file

@ -17,8 +17,9 @@ module.exports = ErrorController =
logger.log err: error,url:req.url, method:req.method, user:req?.sesson?.user, "invalid csrf"
res.sendStatus(403)
return
logger.error err: error, url:req.url, method:req.method, user:req?.sesson?.user, "error passed to top level next middlewear"
if error instanceof Errors.NotFoundError
logger.warn {err: error, url: req.url}, "not found error"
ErrorController.notFound req, res
else
logger.error err: error, url:req.url, method:req.method, user:req?.sesson?.user, "error passed to top level next middlewear"
ErrorController.serverError req, res

View file

@ -221,9 +221,9 @@ module.exports = class Router
headers: req.headers
})
apiRouter.get '/oops-express', (req, res, next) -> next(new Error("Test error"))
apiRouter.get '/oops-internal', (req, res, next) -> throw new Error("Test error")
apiRouter.get '/oops-mongo', (req, res, next) ->
webRouter.get '/oops-express', (req, res, next) -> next(new Error("Test error"))
webRouter.get '/oops-internal', (req, res, next) -> throw new Error("Test error")
webRouter.get '/oops-mongo', (req, res, next) ->
require("./models/Project").Project.findOne {}, () ->
throw new Error("Test error")

View file

@ -1,16 +1,21 @@
extends ../layout
block content
.content
.container
.row
.col-md-8.col-md-offset-2.text-center
.page-header
h2 Oh dear, something went wrong.
p: img(src="/img/lion-sad-128.png", alt="Sad Lion")
p
| Something went wrong with your request, sorry. Our staff are probably looking into this, but it continues, please contact us at #{settings.adminEmail}
p
a(href="/")
i.fa.fa-arrow-circle-o-left
| #{translate("take_me_home")}
doctype html
html(itemscope, itemtype='http://schema.org/Product')
head
title Something went wrong
link(rel="icon", href="/favicon.ico")
link(rel='stylesheet', href='/stylesheets/style.css')
link(href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css",rel="stylesheet")
body
.content
.container
.row
.col-md-8.col-md-offset-2.text-center
.page-header
h2 Oh dear, something went wrong.
p: img(src="/img/lion-sad-128.png", alt="Sad Lion")
p
| Something went wrong with your request, sorry. Our staff are probably looking into this, but if it continues, please contact us at #{settings.adminEmail}
p
a(href="/")
i.fa.fa-arrow-circle-o-left
| Take me home