Hello Jochem,

  seems like we have quite some nice additions to the manual here in this
thread. Now to the real issue, Exceptions don't bubble up. That is they
are simply ignored. And once all __autoload work is done and the class
still doesn't exist an E_ERROR is issued. The work around for cases where
the class must not exist (e.g. when no E_ERROR is needed would be
collecting the exceptions. That is the base Exception class would get an
additional property and getter:
  private $previous_exception;
  function public getPreviousException();
That way we could let the exceptions bubble up (though some smaller engine
changes are necessary).

marcus

Thursday, July 10, 2008, 7:14:33 PM, you wrote:

> Derick Rethans schreef:
>> On Thu, 10 Jul 2008, Gergely Hodicska wrote:
>> 
>>>> exceptions thrown during autoload are ignored.
>>> And one more thing, this is in the manual:
>>> "Note: Exceptions thrown in __autoload function cannot be caught in the 
>>> catch
>>> block and results in a fatal error."
>>>
>>> I think your explanation makes much more clear what happens, maybe it would
>>> worth to upgrade the manual. While the quoted text suggests that that if 
>>> throw
>>> an exception I just can't catch it and will bubble up to top level and this
>>> cause the fatal error.
>> 
>> You can actually catch it *in* the autoload method, it just wouldn't 
>> bubble out of it.

> the manual could do with that tidbit, maybe also the hack for 'getting the
> exception out' of __autoload() ...

>         function __autoload($class)
>         {
>                 try {
>                         throw new Exception('foo');
>                 } catch (Exception $e) {                                
>                     self::handleDebug($e);
>                 
>                     if (!class_exists($class, false))
>                         eval(sprintf('
>                      class %1$s
>                      {
>                          public         function __construct()        {
> throw new AL_Exception("Class %1$s not found: %2$s"); }
>                          public         function __call($m, $a)       {
> throw new AL_Exception("Class %1$s not found: %2$s"); }
>                          public  static function __callStatic($m, $a) {
> throw new AL_Exception("Class %1$s not found: %2$s"); }
>                      }', $class, $e->__toString()));                    
>                 }
>         }

> which works best when __autoload() isn't triggered by class_exists("Foo", 
> true)


>> 
>> regards,
>> Derick
>> 





Best regards,
 Marcus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to