Created
February 6, 2011 17:25
-
-
Save isaiahdw/813529 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 script access.'); | |
class Kohana_Exception extends Kohana_Kohana_Exception { | |
public static function handler(Exception $e) | |
{ | |
if (Kohana::DEVELOPMENT === Kohana::$environment) | |
{ | |
parent::handler($e); | |
} | |
else | |
{ | |
try | |
{ | |
Kohana::$log->add(Log::ERROR, parent::text($e)); | |
$attributes = array | |
( | |
'action' => 500, | |
'message' => rawurlencode($e->getMessage()) | |
); | |
if ($e instanceof Http_Exception) | |
{ | |
$attributes['action'] = $e->getCode(); | |
} | |
// Error sub-request. | |
echo Request::factory(Route::url('error', $attributes)) | |
->execute() | |
->send_headers() | |
->body(); | |
} | |
catch (Exception $e) | |
{ | |
// Clean the output buffer if one exists | |
ob_get_level() and ob_clean(); | |
// Display the exception text | |
echo parent::text($e); | |
// Exit with an error status | |
exit(1); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment