Skip to content

Commit

Permalink
errors: prettier error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Enome committed Jun 14, 2013
1 parent efcbc83 commit 3dc4625
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 4 deletions.
45 changes: 45 additions & 0 deletions errors/error_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
100: 'Continue',
101: 'Switching Protocols',
103: 'Checkpoint',
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-Authoritative Information',
204: 'No Content',
205: 'Reset Content',
206: 'Partial Content',
300: 'Multiple Choices',
301: 'Moved Permanently',
302: 'Found',
303: 'See Other',
304: 'Not Modified',
306: 'Switch Proxy',
307: 'Temporary Redirection',
308: 'Resume Incomplete',
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Timeout',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Request Entity Too Large',
414: 'Request-URI Too Long',
415: 'Unsupported Media Type',
416: 'Requested Range Not Satisfiable',
417: 'Expectation Failed',
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
511: 'Network Authentication Required',
};
48 changes: 45 additions & 3 deletions errors/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,49 @@ html
head
title Jungles - error #{code}

link(href='http://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400italic,700italic,400,300,700', rel='stylesheet', type='text/css')

style.
body {
font-family: 'Roboto Condensed';
background: #6ED2DD;
color: white;
}

.page {
position: absolute;
width: 400px;
height: 600px;
left: 50%;
margin-left: -200px;
text-align: center;
}

h1 {
font-weight: 300;
font-size: 35px;
margin-top: 3em;
}

h2 {
font-size: 50px;
color: #6ED2DD;
font-weight: 400;
background: white;
width: 165px;
height: 165px;
line-height: 165px;
border-radius: 80px;
display: inline-block;
}

h3 {
font-weight: 300;
font-size: 35px;
}

body
center
div(style='width: 400px')
h1= code
.page
h1= error_list[code]
h2= code
h3= url
5 changes: 5 additions & 0 deletions errors/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
var express = require('express');
var error_list = require('./error_list');

var errors = function (app, view) {

app.all('*', function (req, res, next) {
Expand Down Expand Up @@ -25,7 +28,9 @@ var errors = function (app, view) {
console.log('url: ' + req.url);
console.log('--------------------------------------------------');

res.locals.error_list = error_list;
res.locals.code = code;
res.locals.url = req.url;
res.statusCode = code;

res.render(view || __dirname + '/index.jade');
Expand Down
6 changes: 5 additions & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
"keywords": [
"jungles",
"errors"
]
],
"dependencies": {
"express": "~3.2.6",
"jade": "~0.31.2"
}
}

0 comments on commit 3dc4625

Please sign in to comment.