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

Commit

Permalink
Implement 500 page [closes #40]
Browse files Browse the repository at this point in the history
  • Loading branch information
brianloveswords committed Nov 11, 2012
1 parent 86d585d commit 4eb70dd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app.js
Expand Up @@ -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
// --------------------
Expand Down
13 changes: 12 additions & 1 deletion routes/admin.js
@@ -1,6 +1,6 @@
var Badge = require('../models/badge');
var phrases = require('../lib/phrases');

var logger = require('../lib/logger');
/*
* Administrative Pages
*/
Expand Down Expand Up @@ -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');
};
23 changes: 23 additions & 0 deletions views/public/500.html
@@ -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.