Re: How can I detect an exception without using try/catch?
| From: | Stuart | Date: | Fri, 24 Apr 2009 11:25:34 +0000 |
| Subject: | Re: How can I detect an exception without using try/catch? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-291919@lists.php.net to get a copy of this message | ||
2009/4/23 Bill Moran <wmoran@potentialtech.com>:
>
> Specifically, the __destruct() method of certain objects will be
> called if an object goes out of scope due to an exception. Since
> the __destruct() method didn't call the code that caused the
> exception, it can't catch it.
>
> I need the __destruct() method to behave differently if it's
> called while an exception is in progress than if it's called
> simply because the object is unset.
>
> Searches of the docs has yet to turn up anything and Google isn't
> helping. Anyone have any pointers?
As far as I'm aware what you're asking for is not possible. Exception
handlers run without any context - check the return value from
debug_backtrace() in a catch block to see what I mean.
-Stuart
--
http://stut.net/