nloding Posted April 28, 2008 Share Posted April 28, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/103317-error-control-handling-and-messages-suggestions/ Share on other sites More sharing options...
ionik Posted April 29, 2008 Share Posted April 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/103317-error-control-handling-and-messages-suggestions/#findComment-529932 Share on other sites More sharing options...
bholbrook Posted May 22, 2008 Share Posted May 22, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/103317-error-control-handling-and-messages-suggestions/#findComment-547605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.