Skip to content

Commit

Permalink
Fancy error handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
nugget committed Feb 6, 2013
1 parent fe74c11 commit a50915b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
8 changes: 4 additions & 4 deletions webroot/.htaccess
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Options ExecCGI FollowSymLinks

# ErrorDocument 400 /errors/400.php
# ErrorDocument 401 /errors/401.php
# ErrorDocument 403 /errors/403.php
# ErrorDocument 404 /errors/404.php
ErrorDocument 400 /errors/400
ErrorDocument 401 /errors/401
ErrorDocument 403 /errors/403
ErrorDocument 404 /errors/404

<Files "*.inc">
Order Deny,Allow
Expand Down
10 changes: 10 additions & 0 deletions webroot/errors/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Options ExecCGI FollowSymLinks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /errors/

RewriteRule ^(\d+)$ index.rvt?code=$1 [QSA]
RewriteRule ^([^\.\?]+[^\/])$ $1.rvt [QSA]

</IfModule>
48 changes: 48 additions & 0 deletions webroot/errors/index.rvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?
package require ergkeeper

::ergkeeper::page_init
::ergkeeper::page_response

if {[info exists response(code)]} {
sanitize_number response(code)
set code $response(code)
} else {
set code 500
}

headers numeric $code
headers set Cache-Control "no-cache,max-age=0"
headers set Expires [clock format [clock seconds] -format "%a, %d %b %Y %H:%M:%S %Z" -gmt 1]


set title(400) "Bad Request"
set snark(400) "Say what?"

set title(401) "Unauthorized"
set snark(401) "Please stay on the marked trails"

set title(403) "Forbidden"
set snark(403) "Locked doors keep honest people honest"

set title(404) "Not Found"
set snark(404) "Either I am confused or you are."


if {[info exists title($code)]} {
set my_title $title($code)
set my_snark $snark($code)
} else {
set my_title "Unknown Error"
set my_snark "I am totally confused"
}

::ergkeeper::page_head $my_title

puts [head $my_title]

puts "<p>$my_snark</p>"

::ergkeeper::page_foot
::ergkeeper::page_term
?>

0 comments on commit a50915b

Please sign in to comment.