Created
October 2, 2010 11:07
-
-
Save thecancerus/607550 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class ExceptionHook | |
{ | |
public function SetExceptionHandler() | |
{ | |
set_exception_handler(array($this, 'HandleExceptions')); | |
} | |
public function HandleExceptions($exception) | |
{ | |
$msg ='Exception of type \''.get_class($exception).'\' occurred with Message: '.$exception->getMessage().' in File '.$exception->getFile().' at Line '.$exception->getLine(); | |
$msg .="\r\n Backtrace \r\n"; | |
$msg .=$exception->getTraceAsString(); | |
log_message('error', $msg, TRUE); | |
mail('[email protected]', 'An Exception Occurred', $msg, 'From: [email protected]'); | |
} |
This file contains hidden or 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 | |
class MY_Exceptions extends CI_Exceptions { | |
public function __construct() | |
{ | |
parent::CI_Exceptions(); | |
} | |
public function show_php_error($severity, $message, $filepath, $line) | |
{ | |
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; | |
$filepath = str_replace("\\", "/", $filepath); | |
// For safety reasons we do not show the full file path | |
if (FALSE !== strpos($filepath, '/')) | |
{ | |
$x = explode('/', $filepath); | |
$filepath = $x[count($x)-2].'/'.end($x); | |
} | |
if (ob_get_level() > $this->ob_level + 1) | |
{ | |
ob_end_flush(); | |
} | |
ob_start(); | |
include(APPPATH.'errors/error_php'.EXT); | |
$buffer = ob_get_contents(); | |
ob_end_clean(); | |
$msg = 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line; | |
log_message('error', $msg , TRUE); | |
mail('[email protected]', 'An Error Occurred', $msg, 'From: [email protected]'); | |
} | |
} |
You need to set
$config['subclass_prefix'] = 'MY_';
in config.php file
Did you ever find the solution to this @lomse
I have $config['subclass_prefix'] = 'MY_';
but still getting Class 'CI_Exceptions' not found
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,Thanks for the library.
Im having an issue and Im hoping you could help.
I'm using Codeigniter 3.
application/config/hooks.php
In application/libraries/MY_Exceptions.php
I keep getting
Class 'CI_Exceptions' not found
. Thoughts?