Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3606228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:13:20+00:00 2026-05-18T21:13:20+00:00

Can someone guide me in the right direction on how to implement and at

  • 0

Can someone guide me in the right direction on how to implement and at what stage should i add in the error handling code?

Website:
social network like linkedin. Platform is MySql and codeignitor PHP.
Requirement: 3 cases for errors:

  1. Front end like http codes. In this case user is redirected to a std message page. Nothing to capture at DB.

  2. Second case is the back end errors like if server takes too long, error writing to DB, other DB issues, code blowups etc. Expected is the user in all these cases will only see an error message box that “someone has been notified, try again later”. Similar to how it is on facebook except facebook has different error text based on error type.

  3. 3rd error type is session related: Cookies getting disrupted during a session and timeouts occuring in which case display a please login message window.

My question is now:

  1. To capture all various errors that fall within case 2, can it be done at the same time development is in progress or do the developers have to go back and add in the error catching at end of project at each entry point in code which could be millions of lines of code?

  2. My team is telling me they don’t know all possible cases that an error can occur within case 2 until entire development is complete. But i argue that error hadling code is general no matter what. Only addition to code is an error catching clause for the error category we want to capture and the error message to dislay if different which can be added at any time but the underlying error code is same so it can be written even before development starts?

  3. How do I find all the possible or catch for all possible cases an error can occur in case 2 which there can be hundreds of usecases of something blowing up at any level or DB read/write errors, etc. Do we need separate code for each or a common code catching all?

My developers are new too and so am I so I dont think anyone is exactly sure on when and how to approach the error handling on the site. On the backend of system when an error occurs an email will be sent to admin and I am building an error tracking system so we can keeptrack of issues in the backend automatic with status, type, notes, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:13:21+00:00Added an answer on May 18, 2026 at 9:13 pm

    1.To capture all various errors that fall within case 2, can it be done at the same time development is in progress or do the developers have to go back and add in the error catching at end of project at each entry point in code which could be millions of lines of code?

    Both, but generally just needed while development is in progress. It’s actually crucial to consider what types of errors each line of code could produce on its own (especially if grabbing data from external or DB sources), so you need to account for all that at each step. To help insert special case handling after everything is already in place, this is where a master error handling function comes into play. Just take note of what error levels will never even trigger your custom error handling. You may also be interested in the Exception class. Again, to allow for easier inserting of special case handling by only having to make updates in fewer spots, extend the Exception class into your own special error object.

    2.My team is telling me they don’t know all possible cases that an error can occur within case 2 until entire development is complete. But i argue that error hadling code is general no matter what. Only addition to code is an error catching clause for the error category we want to capture and the error message to dislay if different which can be added at any time but the underlying error code is same so it can be written even before development starts?

    Kind of the same question as #1. IMHO, you are correct. And in some cases, so are they. One developer really can’t know what types of errors another developer’s code would generate until they see the code or get a hold of its final documentation.

    3.How do I find all the possible or catch for all possible cases an error can occur in case 2 which there can be hundreds of usecases of something blowing up at any level or DB read/write errors, etc. Do we need separate code for each or a common code catching all?

    Again going off question #1, using custom error handling functions or extending off the Exception class (even making separate classes for handling DB try/catches vs file access try/catches, etc), this should help significantly. Say you discover a new possible error your DB could spit out. If you already have the connect and query functions wrapped in try/catch blocks, you need only add the handling script in your extended Exception class, and not wherever your DB functions exist. For example, you may opt to just do something like this for all your db connects. DB_Exception in this cases is your extended version of Exception, which could itself do any number of troubleshooting tasks on its own:

    function db_connect() {
        $MySQLi = new mysqli(DB_HOST, DB_USERNAME, DB_PW, DB_NAME, DB_PORT, DB_SOCKET);
        if ($MySQLi->connect_error) throw new DB_Exception($MySQLi->connect_error);
        if ($MySQLi->error) throw new DB_Exception($MySQLi->error);
        return $MySQLi;
        }
    
    try {$MySQLi = db_connect();}
    catch (DB_Exception $e) {if (!$e->is_fixed_now) die($e->special_message);}
    

    You could also have your extended Exception class reference a set of canned responses enumerated by the $code construct argument. But, you really should not try to apply special error handling to every conceivable DB error you may get. It’s much more efficient and way less a burden to most of the time just grab the MySQL error text whatever it may be and forward that to your admins.

    As for the text you display to the user, it’s best to always keep it simple and informative while giving absolutely nothing away about the inner workings of your website. Example: your DB server crashes or someone mistakenly misset file permissions: all you should tell the user is "Sorry, technical difficulties, this particular content is not available just now, our staff has been notified, please try again later. If urgent email so@so.com or call support at 555-1212.". You could also do the canned message based off the Exception $code argument, same as above, but give nothing that will help in the event of a site attack.

    Also, "On the backend of system when an error occurs an email will be sent to admin" Not actually a good idea. The user may just sit there hitting refresh over and over until it magically starts working again. You could easily be caught in an email storm. One possible solution is to run a 10-minute cron job checking to see if the error log has been modified in the last 10 minutes, and email a summary of new log entries instead. Or, if you have a trouble ticket system, have the error script open one only if an open ticket on the topic doesn’t exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone can guide me as I'm stuck... I need to write an
Can someone show me how to implement a recursive lambda expression to traverse a
can someone guide me? Is it possible to get information of .class file (in
Can someone explain the mechanics of a jump table and why is would be
Can someone give an example of a good time to actually use unsafe and
Can someone describe what a symbol table is within the context of C and
Can someone explain to me the advantages of using an IOC container over simply
Can someone explain this result to me. The first test succeeds but the second
Can someone explain what exactly the string 0 but true means in Perl? As
Can someone explain what are the benefits of using the @import syntax comparing to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.