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
https://forums.phpfreaks.com/topic/47470-errror-handling-do-and-donts/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.