Permalink
Browse files

improved 404 error output; now in app layout

  • Loading branch information...
BigBlueHat committed May 16, 2012
1 parent 3a8b35b commit a5abd376928213c0716802e73c67e9b96eafdbbe
Showing with 13 additions and 4 deletions.
  1. +9 −3 routes/beers.php
  2. +4 −1 routes/breweries.php
View
@@ -22,7 +22,7 @@ function breweryUrl($name) {
$app->get('/beers/:id', function($id) use ($app, $cb) {
if (!isset($_SESSION['email'])) {
- $app->response()->status(401);
+ $app->halt(401);
} else {
$beer_id = 'beer_' . str_replace(' ', '_', urldecode($id));
$beer = json_decode($cb->get($beer_id));
@@ -34,7 +34,10 @@ function breweryUrl($name) {
$content = $app->view()->render('beer.mustache');
$app->render('layout.mustache', compact('content'));
} else {
- $app->notFound();
+ $app->render('layout.mustache',
+ array('content' => '<h1>404 - Beeer not found...how sad.'),
+ 404);
+ exit;
}
}
});
@@ -54,7 +57,10 @@ function breweryUrl($name) {
$beer_id = 'beer_' . str_replace(' ', '_', urldecode($id));
if ($cb->get($beer_id) === null) {
- $app->halt(404);
+ $app->render('layout.mustache',
+ array('content' => '<h1>404 - Beeer not found...how sad.'),
+ 404);
+ exit;
}
$email = sha1($_SESSION['email']);
if ($cb->get($email) !== null) {
View
@@ -29,6 +29,9 @@
$content = $app->view()->render('brewery.mustache');
$app->render('layout.mustache', compact('content'));
} else {
- $app->notFound();
+ $app->render('layout.mustache',
+ array('content' => '<h1>404 - Brewery not found...how sad.'),
+ 404);
+ exit;
}
});

0 comments on commit a5abd37

Please sign in to comment.