Jump to content

errror handling do and don'ts?


Catzwolf

Recommended Posts

Hi all,

 

I am using a user defined function to handle php and system (userdefined errors) in a singleton class.

 

Now I use this class to handle php errors and I aslo want it to handle user defined errors. Will this cause any problems than I am not aware of?

 

example

 

set_error_handler( 'MyErrorHandler_HandleError' );

    function handleError( $errno, $errstr, $errfile, $errline ) {
        //do error stuff here
    }

function MyErrorHandler_HandleError( $errNo, $errStr, $errFile, $errLine, $errContext = null ) {
    $_eh = &error_handler::instance();
    $_eh ->handleError( $errNo, $errStr, $errFile, $errLine, $errContext );
}

 

I use the above to trap php errors to output later.

 

Now, I want to use this to handle user defined errors, like a database insert that failed or if a user entered a wrong password. Could I pass user defined error via this handler? Would this cause problems else where?

 

MyErrorHandler_HandleError( '1002', 'Failed to to login, wrong username or password', __FILE__, __LINE__,  null ); 

 

Sorry if this doesn't seem clear enough lol

 

Thanks

 

Catz

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.