Created
March 29, 2012 19:16
-
-
Save Javlopez/2242361 to your computer and use it in GitHub Desktop.
Kohana_Exception
This file contains 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 | |
class Kohana_Exception extends Kohana_Kohana_Exception { | |
static public function handler(Exception $e) | |
{ | |
if (Kohana::$environment === Kohana::DEVELOPMENT) | |
{ | |
parent::handler($e); | |
} | |
else | |
{ | |
Kohana::$log->add(Kohana_Log::ERROR, Kohana_Exception::text($e)); | |
$request = array( | |
// 500 error by default | |
'controller' => 'error', | |
'action' => 500, | |
// If exception has a message this can be passed on | |
'id' => rawurlencode($e->getMessage()), | |
); | |
// Override status if HTTP_Exception thrown | |
if ($e instanceof HTTP_Exception) | |
{ | |
$request['action'] = $e->getCode(); | |
} | |
if($e instanceof HTTP_Exception_404) | |
{ | |
$request['id'] = 'La url a la que intento ingresar no existe'; | |
$request['action'] = 404; | |
} | |
if (Kohana::$environment === Kohana::DEVELOPMENT) | |
{ | |
throw $e; | |
} | |
echo Request::factory(Route::get('default')->uri($request)) | |
->execute() | |
->send_headers() | |
->body(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment