Jump to content

Recommended Posts

So it has recently occurred to me that my method of error handling is sloppy and cumbersome. What I want to do is record all of the errors that occur and allow the page to finish loading. Then display them in a designated error panel on my page.

 

Granted that if I come across a major error I do want to stop the script but for minor errors such as incorrect credentials or some other custom error I may want to display I want to neatly display them all without stopping the script.

 

Can anyone offer any advice?

  • 1 month later...

You can try to use different types of Exception. You use a "User_Exception" if you have invalid input data or something like that, and a "Database_Exception" for great errors, like loose connection.

 

It can be like this:

 

try {
    $newUser = new User();
    $newUser->setCredentials('user', 'pass');
    $newUser->insert();
} catch (Database_Exception $e) {
   // log this error
   // stop the script
} catch (User_Exception $e) {
   // Display the error
}

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.