Created
May 3, 2011 20:16
-
-
Save averyaube/954134 to your computer and use it in GitHub Desktop.
Error Handling Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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