[eluser]Unknown[/eluser]
I recently started developing with CodeIgniter and it has been a great help for me. But at the moment I'm struggling with handling my errors/exceptions and so I needed to extended the base CI_Exceptions class. I have done something similar with the core Controller and it worked very good.
So I did the same:
- I created inside application/libraries a class with my prefix (CL_) : CL_Exceptions
- The class extends from CI_Exceptions
- I added some code for doing stack traces and e-mailing
But none of the functionality gets overridden. The class is autoloaded: I can see if deliberately add some erroneous code.
What might be the problem?
Here is the class:
Code:
<?php
class CL_Exceptions extends CI_Exceptions
{
public function __construct()
{
parent::__construct();
}
function show_error($heading, $message, $template = 'error_general', $status_code = 500) {
try {
$str = parent::show_error($heading, $message, $template = 'error_general', $status_code = 500);
throw new Exception($str);
} catch (Exception $e) {
$msg = $e->getMessage();
$trace = "<h1>Call Trace</h1><pre>". $e->getTraceAsString(). "<pre>";
//append our stack trace to the error message
$err = str_replace('</div>', $trace . '</div>', $msg);
echo $err;
}
}
}