note 96446 deleted from language.oop5.decon by cmb
| From: | cmb@php.net | Date: | Sun, 08 Sep 2019 10:24:12 +0000 |
| Subject: | note 96446 deleted from language.oop5.decon by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212136@lists.php.net to get a copy of this message | ||
Note Submitter: thomasrutter
----
The manual page says that throwing an exception from a destructor causes a fatal error; I've
found that this only happens when the exception is _uncaught_ within the context of that destructor.
If you catch it within that same destructor it seems to be fine.
This is equally true of other contexts, such as:
- shutdown functions set with register_shutdown_function
- destructors
- custom session close functions
- custom error handlers
- perhaps other similar contexts
An exception normally 'bubbles up' to higher and higher contexts until it is caught, but
because a destructor or shutdown function is called not within execution flow but in response to a
special PHP event, the exception is unable to be traced back any further than the destructor or
shutdown function in which it is called.