diff options
author | Andrey Andreev <narf@devilix.net> | 2014-10-28 22:46:45 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-10-28 22:46:45 +0100 |
commit | 4b838af40d77684539dd40461bd92e6e453fe675 (patch) | |
tree | e998edf78ebbd6e1784e858789ad4fa49a159fd1 /system/core/Exceptions.php | |
parent | 2a86f07f4639c0a25df977c00cef23b8f34f9475 (diff) |
Add a real exception handler
Close #1590
Close #3200
Diffstat (limited to 'system/core/Exceptions.php')
-rw-r--r-- | system/core/Exceptions.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 6324fba2b..0531a4e92 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -187,6 +187,44 @@ class CI_Exceptions { // -------------------------------------------------------------------- + public function show_exception(Exception $exception) + { + $templates_path = config_item('error_views_path'); + if (empty($templates_path)) + { + $templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR; + } + + $message = $exception->getMessage(); + if (empty($message)) + { + $message = '(null)'; + } + + if (is_cli()) + { + $templates_path .= 'cli'.DIRECTORY_SEPARATOR; + } + else + { + set_status_header(500); + $templates_path .= 'html'.DIRECTORY_SEPARATOR; + } + + if (ob_get_level() > $this->ob_level + 1) + { + ob_end_flush(); + } + + ob_start(); + include($templates_path.'error_exception.php'); + $buffer = ob_get_contents(); + ob_end_clean(); + echo $buffer; + } + + // -------------------------------------------------------------------- + /** * Native PHP error handler * |