-
Aug 13th, 2004, 02:42 AM
#1
Error Handler Class
I just finished creating an error handling class in PHP. The source code is here:
http://www.sccode.com/projects/filem...src/error.phps
The documentation here:
http://www.sccode.com/projects/filem...r_handler.html
Feel free to use it if you like it and if you have any comments or suggestions, please let me know. Here's a quick code snippet demonstrating its use:
PHP Code:
<?php
include_once 'error.php';
$err = &new error;
$err->logpath = 'myerror.log';
$err->fatal_error_function = Array('friendly_exit');
$err->email_on_errors = true;
$err->email_send = 2;
$err->admin_email = 'me@mydomain.com';
$err->email_subject = 'My Custom Error Script';
/* this will produce a notice */
echo ($undefiend);
echo ('this will be seen');
/* start an output buffer */
ob_start();
/* so will this */
$defined = hello;
echo ('you will never see this');
/* this will produce a warning */
fputs($none, 'error');
/* this will produce a fatal error and end the script */
trigger_error('This is a fatal error. Bye bye.', E_USER_ERROR);
function friendly_exit()
{
/* clear the current ouput buffer (if any)*/
if (ob_get_level() >= 1) ob_end_clean();
echo ('<h3>Error</h3>');
echo ('<p>I\\'m sorry, this application has had to terminate. Our maintainance team are aware of the problem and ');
echo ('are working to rectify it as soon as possible.</p>');
}
?>
-
Aug 13th, 2004, 07:29 AM
#2
Frenzied Member
I've been meaning to write something like this. Thanks for doing the work for me.
-
Aug 18th, 2004, 11:11 AM
#3
Just updated the class. It had a small bug in it.
-
Jul 5th, 2008, 06:54 PM
#4
My usual boring signature: Something
-
Jul 6th, 2008, 02:39 AM
#5
-
Jul 6th, 2008, 01:14 PM
#6
Re: Error Handler Class
ok great thanks! I might use it on a project that i am working on.
My usual boring signature: Something
-
Jul 6th, 2008, 02:28 PM
#7
Re: Error Handler Class
Might be a nice idea to have a switch so that if on, when the email is sent, include the POST and GET vars, this would help identify the cause of the error, and also to catch people trying to hack it.
-
Jul 6th, 2008, 03:05 PM
#8
Re: Error Handler Class
for admin_email can i include more then one email?
My usual boring signature: Something
-
Jul 6th, 2008, 03:17 PM
#9
Re: Error Handler Class
It uses the PHP mail function, so there should not be an issue if you separate the addresses with a comma.
-
Jul 6th, 2008, 03:31 PM
#10
Re: Error Handler Class
ok i will try. The reason is i would like to have the script send an email to ME and then to the webmaster, who ever that is.
My usual boring signature: Something
-
Jul 6th, 2008, 03:45 PM
#11
Re: Error Handler Class
I am the webmaster. Done you remember?
-
Jul 6th, 2008, 04:02 PM
#12
Re: Error Handler Class
silly me
My usual boring signature: Something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|