|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-01-18 08:26 UTC] felixcca at yahoo dot ca
[2011-01-16 22:24 UTC] stas@php.net
[2011-01-16 22:26 UTC] stas@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: stas
[2011-01-16 22:26 UTC] stas@php.net
[2011-05-17 07:54 UTC] paul at annesley dot cc
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 08:00:01 2025 UTC |
Description: ------------ Basically a duplicate of #31304, but it seems I can't reopen the ticket myself since I'm not a dev nor the original poster. When an exception is thrown in a destructor, the exception is lost, and a pointless Fatal Error is issued: Fatal Error: Exception thrown without a stack trace debug_backtrace() will still get you a stack trace from a destructor without issuing any error, let alone causing the loss of debugging data. Also, only wrapping the exception in a try-catch inside the destructor works, and allows you to just print the exception and exit as if exceptions really worked in destructors. Why spit out the Fatal Error? Reproduce code: --------------- <?php class ExceptionThrower { public function __destruct() { throw new Exception; } } $obj = new ExceptionThrower; ?> Expected result: ---------------- Fatal error: Uncaught exception 'Exception' in snippet.php:6 Stack trace: #0 [internal function]: ExceptionThrower->__destruct() #1 {main} thrown in snippet.php on line 6 Actual result: -------------- Fatal error: Exception thrown without a stack frame in Unknown on line 0