[eluser]Treeda[/eluser]
Hi guys,
i just found out that exceptions are not get globally handled.
well for a live application i would love to catch each uncatched exception and forward me as email or write them to a log
i did the following modification to the codeigniter main file.
This change allows you to add a function named "_unhandled" to your controller class.
This methid is called always if an unhandled exception occurs in your controller and you can do what you want.
I just want to know what do you think about this?
Code:
Original Code
// Call the requested method.
// Any URI segments present (besides the class/function) will be passed to the method for convenience
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
Code:
Modified Code as a suggestion
// Call the requested method.
// Any URI segments present (besides the class/function) will be passed to the method for convenience
try{
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
}
catch( Exception $e ){
if ( method_exists(&$CI,"_unhandled") )
call_user_func_array(array(&$CI, "_unhandled"), $e);
}
in your controllers you can add the exception handler like this
Code:
public function _unhandled( $e){
print "oops";
}