Permalink
Browse files

Implement 500 page [closes #40]

  • Loading branch information...
1 parent 86d585d commit 4eb70ddac631684ca19bd5f513e207ffc6153477 @brianloveswords brianloveswords committed Nov 11, 2012
Showing with 41 additions and 3 deletions.
  1. +6 −2 app.js
  2. +12 −1 routes/admin.js
  3. +23 −0 views/public/500.html
View
@@ -48,17 +48,21 @@ app.configure(function () {
}));
app.use(issuer.getIssuerConfig());
app.use(app.router);
+
// if we've fallen through the router, it's a 404
app.use(admin.notFound);
});
app.configure('development', function () {
+ app.get('/500', admin.nextError);
app.use(express.errorHandler());
});
+app.configure('production', function () {
+ app.use(admin.errorHandler);
+});
+
/** Routes */
-// Route middleware
-// ----------------
// Issuer configuration
// --------------------
View
@@ -1,6 +1,6 @@
var Badge = require('../models/badge');
var phrases = require('../lib/phrases');
-
+var logger = require('../lib/logger');
/*
* Administrative Pages
*/
@@ -141,5 +141,16 @@ exports.userList = function userList(req, res, next) {
};
exports.notFound = function notFound(req, res, next) {
+ res.status(404)
return res.render('public/404.html', {});
};
+
+exports.nextError = function nextError(req, res, next) {
+ return next(new Error('some error'));
+};
+
+exports.errorHandler = function (err, req, res, next) {
+ logger.error('there was an error at ' + req.url, err);
+ res.status(500);
+ return res.render('public/500.html');
+};
View
@@ -0,0 +1,23 @@
+{% extends "public/layout.html" %}
+{% block head %}
+ <link rel="stylesheet" href="/stylesheets/criteria.css">
+{% endblock %}
+{% block body %}
+ <div class="row">
+ <div class="span7">
+ <h2>Mozilla Webmaker Badges</h2>
+ </div>
+ </div>
+ <div class="media card">
+ <!-- <img class="img badge" src=""> -->
+ <div class="bd">
+ <hgroup>
+ <h1>Oh no! Something went wrong</h1>
+ </hgroup>
+ <p>
+ There was a problem trying to do whatever you just tried to
+ do. Please try again later.
+ <p>
+ </div>
+ </div>
+{% endblock %}

0 comments on commit 4eb70dd

Please sign in to comment.