Error Handler Class-VBForums
Results 1 to 12 of 12

Thread: Error Handler Class

  1. #1

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    Lightbulb 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() >= 1ob_end_clean();
        
        echo (
    '<h3>Error</h3>');
        echo (
    '<p>I\\'m sorrythis application has had to terminateOur maintainance team are aware of the problem and ');
        echo ('
    are working to rectify it as soon as possible.</p>');
    }
    ?>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    I've been meaning to write something like this. Thanks for doing the work for me.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904
    Just updated the class. It had a small bug in it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,327

    Re: Error Handler Class

    fail. 404 Error



    edit:
    along with this:
    http://www.sccode.com/projects/filem...n_handler.html

  5. #5

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    Re: Error Handler Class

    Fixed.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,327

    Re: Error Handler Class

    ok great thanks! I might use it on a project that i am working on.

  7. #7
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    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.
    Chris

  8. #8
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,327

    Re: Error Handler Class

    for admin_email can i include more then one email?

  9. #9

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,327

    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.

  11. #11

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    Re: Error Handler Class

    I am the webmaster. Done you remember?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  12. #12
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,327

    Re: Error Handler Class

    silly me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.