Re: exceptions in the destructor

From: Date: Fri, 16 Dec 2005 19:38:20 +0000
Subject: Re: exceptions in the destructor
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-21259@lists.php.net to get a copy of this message
Hello Daine, marcus@zaphod /usr/src/PHP_5_1 $ php -r 'class A{function __destruct(){throw new Exception("A");}} new A;' make: `sapi/cli/php' is up to date. Fatal error: Uncaught exception 'Exception' with message 'A' in Command line code:1 Stack trace: #0 Command line code(1): A::__destruct() #1 {main} thrown in Command line code on line 1 As the code above clearly show, exceptions can be thrown. marcus Friday, December 16, 2005, 3:17:54 PM, you wrote: > Is there any reason why one is not allowed to throw an exception in the > destructor of a class? > I mean, it makes sense, considering this is not always the final step of code, > and it is usually used for finalising things, and it would be a good idea to > know if anything goes wrong at that stage. > Otherwise is there any compromise one can use to "emulate" this feature? > Daine Mamacos. > -- > random signature Best regards, Marcus

« previous php.internals (#21259) next »