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 127037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:24:46+00:00 2026-05-11T05:24:46+00:00

I’m developing some lower end code in my system that uses multiple child classes

  • 0

I’m developing some lower end code in my system that uses multiple child classes of the php exception class. Essentially I have the exceptions broken up to a few categories. What I’m wanting to do is two things.

  1. I need all exceptions that are fired in the application to be handled in a single place.
  2. I need to be able to log and then handle/generate the view for the user to receive feedback on the apps. error.

What I’m wondering is should I have some sort of try/catch encapsulating the application? I don’t like that idea at all, it sounds like a very crappy implementation. I also don’t like the idea of set_exception_handler unless i can sett the function to be a method of an object. The reason for this is that if I designate a function to handle the exceptions this will be the first function in the application. Everything else is a method of an object.

Hopefully I’ve provided enough details about the scenario. I’m trying to keep this clean and follow best practices. This code will be going OSS so I don’t feel like writing it 10 times 🙂

  • 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. 2026-05-11T05:24:47+00:00Added an answer on May 11, 2026 at 5:24 am
    1. Run your web requests through a Front Controller script
    2. call set_exception_handler early in execution (don’t forget to account for error_reporting()). set_exception_handler takes as its paramter what php calls a ‘callback’. You can pass an object method like so:

      // $object->methodName() will be called on errors set_exception_handler(array($object, 'methodName')); 
    3. Wrap your dispatching code with try/catch to catch any code that DOES throw exceptions. The catch part of your code will catch all your own codes’ exceptions, plus some php errors that didn’t generate an exception natively (eg fopen or something), thanks to your set_exception_handler call above. The php manual states:

      The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.

    4. Log errors as necessary.

    5. Create an error page template (the ‘View’) that operates on an Exception object (the ‘Model’) and pretty prints the whole stack trace for you, in development. Create a different template that goes to production. Branch on your environment, for example:

      catch(Exception $e) {     // log error as necessary here.     if('in developement') {         // $e would be available to your template at this point         include 'errortemplates/dev.php';     } else {         include 'errortemplates/prod.php';     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 154k
  • Answers 154k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Because you might want to have public constructors but not… May 12, 2026 at 10:33 am
  • Editorial Team
    Editorial Team added an answer Update: See the top-voted answer please. My own is currently… May 12, 2026 at 10:33 am
  • Editorial Team
    Editorial Team added an answer You don't mention a programming language but here is how… May 12, 2026 at 10:33 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.