I just ran into this issue again:

http://stackoverflow.com/questions/2429642/why-its-impossible-to-throw-exception-from-tostring

Instead of throwing some nonsense "you're not allowed to throw from here"
error-message, how about actually unwinding the stack and passing the
exception to the global exception-handler?

I understand there's a technical limitation making it difficult/impossible
to handle exceptions during __toString() - and it looks like you can still
try {...} catch (Exception $e) in __toString() just fine, but then what?
You have the exception, but you have no way to pass it to the standard
global exception-handler.

If the script has to terminate either way, why not terminate the same way
an unhandled exception would normally cause the script to terminate?

E.g. output the actual error-message, or pass it to whatever was registered
with register_exception_handler() so it can be output or handled in the
usual way?

Reply via email to