Skip to content

Instantly share code, notes, and snippets.

@averyaube
Created May 3, 2011 20:16
Show Gist options
  • Save averyaube/954134 to your computer and use it in GitHub Desktop.
Save averyaube/954134 to your computer and use it in GitHub Desktop.
Error Handling Controller
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Error extends Controller_Base {
public function before()
{
if ( ! method_exists($this, 'action_'.$this->request->action()))
{
// Default error message will be the 500
$this->request->action('500');
}
parent::before();
}
public function action_500()
{
$this->view->title = 'An error occurred.';
$this->view->message = 'Something strange happened! Please try again.';
$this->renderWithLayout($this->view);
}
public function action_404()
{
$this->view->title = 'Page not found.';
$this->view->message = 'The page you are looking for doesn\'t exist!';
$this->renderWithLayout($this->view);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment