Jump to content

Error control, handling, and messages -- suggestions


nloding

Recommended Posts

I'm looking for some broad suggestions as to handling errors and ways that you guys handle errors in your own applications.  More specifically, this is related to displaying the error to the user in a meaningful way.  And, even more specifically, I'm talking about user errors, not "Could not query database."

 

For instance, my first user auth script had a $error array that was as follows: $error['username'][1] = "Invalid username", $error['username'][2] = "No username entered", etc.  This worked on the small scale I was working with, now I'm up to a larger scale and looking for some pointers.

 

I was thinking of having a table of "known errors" and querying based on that, but that still requires that the programmer 'know' the ID of the error they want displayed.  I can't think of any more automated way to do that, though.  And then have a $object->hasError boolean, and a $object->errMsg string, then use an if/else, and print a span/div on the site on the bad part.

 

What do you guys do?

Link to comment
Share on other sites

Personally,

 

I do not handle errors that a user can generate on a large scale basis.

 

Reasons being is that a user can come across alot of errors that you may have overlooked in your development.

 

I myself have built a complete error handling that works for all errors that could show up MySQL, PHP and User Errors simply displays the normal website just drops any content and shows the error message, logging everything, there are more things but you get the picture.

 

What I do for user errors such as invalid logins etc is use a function I created die_message() it works efficently and theres no need to remember any error handling identifiers as you can just simply input the error message it shows the error logs it etc etc..

 

Personally I dont recommend trying to make a table having a list of errors unless they come form PHP and MySQL still you wouldnt need one.

Link to comment
Share on other sites

  • 4 weeks later...

Personally I dont recommend trying to make a table having a list of errors unless they come form PHP and MySQL still you wouldnt need one.

 

I would 100% disagree with this, especially as we enter the age of Web 2.0 and AJAX websites. Anytime I send an async request, I return my expected value, or an error code (ERR:00190). This error code can then be sent back in to another script as another async request with two parameters, the language and the error number:

 

--using YUI & Javascript

YAHOO.util.Connect.asyncRequest("GET","error.php?err=00190&lang=en",{...},null);

 

This will go to error.php which will pull the error in the language requested and can be displayed with your Javascript handler. Goto http://developer.yahoo.com/yui for info on YUI.

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.