-
-
Save biakaveron/831603 to your computer and use it in GitHub Desktop.
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 defined('SYSPATH') or die('No direct access allowed.'); | |
/** | |
* Kohana-World Exception Handler | |
* | |
* @package KW-Core | |
* @author Kohana-World Development Team | |
* @license MIT License | |
* @copyright 2011 Kohana-World Development Team | |
*/ | |
class Kw_Exception_Handler { | |
/** | |
* Error handel method | |
* @static | |
* @param Exception $e | |
* @return boolean|string | |
*/ | |
public static function handle(Exception $e) | |
{ | |
// Throws Kohana_Exception if not in PRODUCTION environment | |
if(Kohana::$environment > Kohana::PRODUCTION) | |
return Kohana_Exception::handler($e); | |
// Catches Http_Exceptions and show them in sexy view | |
if ($e instanceof Http_Exception) | |
{ | |
$uri = 'error/' . $e->getCode(); | |
} | |
// Catches other exceptions and show them as common errors | |
else | |
{ | |
$uri = 'error'; | |
} | |
$response = Request::factory($uri)->execute(); | |
// If Exception was thrown in HMVC Request, send error handled response to Request::$current | |
if(Request::$current) | |
{ | |
echo Request::$current->response($response); | |
} | |
// Else to Request::$initial | |
else | |
{ | |
echo Request::$initial->response($response); | |
} | |
} | |
} // End Kw_Exception_Handler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment