views:

29

answers:

0

It is known that __toString cannot throw an exception but I have read ( Link 1, Link 2 ) that it supports trigger_error so I tried the following code:

    public function __toString() {
        try {
            return $this->render();
        } catch (Exception $e){
            trigger_error($e->getMessage());
            return '';
        }       
}   

But still I received: __toString() must not throw an exception. I have tried removing trigger_error and all works fine, but I understand this code should work, why does it not? Do I have any other options, or should I just do a die($e->getMessage); instead?