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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:02:10+00:00 2026-05-30T20:02:10+00:00

[EDIT – Disclaimer: This is a really bad idea, see the accepted answer for

  • 0

[EDIT – Disclaimer: This is a really bad idea, see the accepted answer for an actual solution.]

I define my own exception handler using set_exception_handler() function. After the handler execution, I need the script to continue. Is there any way to do it?

Disclaimer: I know try-catch blocks but I need to process Exceptions dynamicaly. Every calling of Clazz::foo() specifies its own exceptions which should be caught by my handler. That’s the reason I can’t use it.

Example:

class Clazz {

    private static $exceptions;

    public static function foo(array $exceptions) {
        set_exception_handler(array(__CLASS__, "exception_handler"));
        self::$exceptions = $exceptions;
        throw new RandomException;
        echo "I need this to be printed!";
    }

    public static function exception_handler($exception) {
        // process the exception in my way...
        // if $exception in self::$exceptions than 1, else 2, fi
        restore_exception_handler();
        // continue in some way, like it has never happenned
    }

}
  • 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-30T20:02:12+00:00Added an answer on May 30, 2026 at 8:02 pm

    This is just bad idea. I just hope you don’t understand how Exceptions work and you’re not meaning the question.

    First of all, setting exception handler… Exception handler is called when the exceptions is propagated to main script (actually out of it) and your script is therefore done:

    Sets the default exception handler if an exception is not caught within a try/catch block. Execution will stop after the exception_handler is called.

    You should either use what’s Xeoncross suggesting, but I think you have problem with called function/method that is throwing exceptions so you can do this:

    class Clazz {
    
        private static $exceptions;
    
        public static function foo(array $exceptions) {
            set_exception_handler(array(__CLASS__, "exception_handler"));
            self::$exceptions = $exceptions;
            try {
                throw new RandomException;
            } catch( Exception $e){
                self::exception_handler( $exception);
            }
            echo "I need this to be printed!";
        }
    
        public static function exception_handler(Exception $exception) {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: I have solved this by myself. See my answer below I have set
EDIT: looking for this: http://diminishing.org/extending-formtastic-with-a-sprinkle-of-jquery (If this works I'll answer my own question) I've
Edit 4: I was finally able to solve my own issue. See checkmark answer
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT After staring at this for 2 days, I do see one issue. I
Edit: Seems numerous people think this is a dumb idea, so I would appreciate
[Edit: Apparently, this is only an issue for arrays and FoxyBOA's answer might direct
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot

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.