Hey,

> I have a question: is there any reason to throw an exception from
> __toString, *other* than a non-recoverable error, which would denote that
> the object, which the __toString method is called on, does not have any
> meaningful string representation? Because if not, core implementation fully
> serves its purpose throwing Fatal error now, even if it is non-standard way.

The problem with not enabling __toString to throw exceptions is that if any
exceptions thrown are by the engine itself (for things like uncallable 
functions),
then the method returns an unrelated E_ERROR regarding the inability to
throw exceptions.

The code example [1] shows this where the old message was:
"Fatal error: Call to undefined function a() in..."

and now after the inclusion of exceptions in the engine, it is:
"Fatal error: Method Test::__toString() must not throw an exception in..."

This is obviously not an overly helpful response, and the E_ERROR cannot be
caught either.

Thanks,
Tom

[1] http://3v4l.org/eGc1d

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

Reply via email to