Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

[PHP] Error handling with one level of abstraction

Options
  • 06-04-2012 7:01pm
    #1
    Registered Users Posts: 4,475 ✭✭✭


    I've got a database class that handles all my db calls, and it's scattered liberally throughout my site as it should be. I've also got an error handler that posts me an email when something goes wrong. This simply catches the error and posts me the filename and line number where it occurred.

    However, it seems that by far the most common error on my site is data related - bad data, missing fields, whatever. The problem (you can see it coming, can't you), all my error handler returns is the database class name and the line that executes the db call. I get the sql that's been called which is some help, but it would be handy to know the original filename and line. I can use $_SERVER to get the former but no way of getting the latter, apparently.

    Short of sending some extra parameters to the db class every time I call it, or (worse) ripping out the db class, am I stuck?


Comments

  • Registered Users Posts: 4,475 ✭✭✭corblimey


    Solved it! Using the debug_backtrace() command returns an array of the entire list of calls. Sorted


Advertisement