Skip to content

Instantly share code, notes, and snippets.

@biakaveron
Forked from smgladkovskiy/kohana_exception.php
Created February 17, 2011 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biakaveron/831603 to your computer and use it in GitHub Desktop.
Save biakaveron/831603 to your computer and use it in GitHub Desktop.
<?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