Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

[PHP] Error handling with one level of abstraction

  • 06-04-2012 07:01PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


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


Advertisement