Re: __autoload & exceptions

From: Date: Sun, 12 Oct 2003 10:59:23 +0000
Subject: Re: __autoload & exceptions
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-4803@lists.php.net to get a copy of this message
Hello Dan, Sunday, October 12, 2003, 7:34:59 AM, you wrote: > This behaviour isn't a show stopper. It's just the inconsistency that > bugs me. yes! > I'm left wondering what other ways the engine might handle my exceptions > that > I might not expect, like... > try { > function __autoload($x) { throw new Exception(); } > $foo = new bar(); > } > catch (Exception $e) { print('caught exception'); } > The exception will never be caught in this case (resulting in the same previous > error). A PHP engine developer might look at that and say something like "oh, of > course it doesn't. The engine removes the special __autoload function from the > main try/catch block at compile time." Now try explaining why it would do this to > your average PHP user. ;) Yes, that's a valid point that goes to you. But this can be delayed until after PHP 5 release right? > Luckily, using a try/catch block *inside* the __autoload function works fine. Its just > not at all able to pass the exception on up the chain. Meaning people need to keep > in mind that any and all objects/methods/etc. which could throw exceptions that may > have been called from inside their __autoload function will only get those exceptions > passed as high as the autoloader for handling instead of their main code. > If this is intended behaviour, then this is just a recommendation for a note in the > future documentation of __autoload. As said lat's delay and document it. Maybe someone finds an appropriate nice solution later. Feel free to make this a documnetation bug. -- Best regards, Marcus mailto:helly@php.net

« previous php.internals (#4803) next »