summaryrefslogtreecommitdiffstats
path: root/system/core/Exceptions.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-10-28 22:46:45 +0100
committerAndrey Andreev <narf@devilix.net>2014-10-28 22:46:45 +0100
commit4b838af40d77684539dd40461bd92e6e453fe675 (patch)
treee998edf78ebbd6e1784e858789ad4fa49a159fd1 /system/core/Exceptions.php
parent2a86f07f4639c0a25df977c00cef23b8f34f9475 (diff)
Add a real exception handler
Close #1590 Close #3200
Diffstat (limited to 'system/core/Exceptions.php')
-rw-r--r--system/core/Exceptions.php38
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
*