#50699 [Opn->Bgs]: Cannot throw Exceptions in __toString()

From: Date: Fri, 08 Jan 2010 22:24:10 +0000
Subject: #50699 [Opn->Bgs]: Cannot throw Exceptions in __toString()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146455@lists.php.net to get a copy of this message
 ID:               50699
 Updated by:       bjori@php.net
 Reported By:      gmblar+php at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: *
 PHP Version:      5.3.1
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

__toString() must not throw exceptions


Previous Comments:
------------------------------------------------------------------------

[2010-01-08 22:22:35] gmblar+php at gmail dot com

Description:
------------
Cannot throw Exceptions in __toString(). Instead it produces a Fatal 
error.

Reproduce code:
---------------
<?php

class bar {

    public function __toString() {
        throw new Exception('Incomplete Data');
    }

}

$foo = new bar();
echo $foo;

?>





Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'Incomplete 
Data' in /-:6

Actual result:
--------------
Fatal error: Method bar::__toString() must not throw an exception in /-

on line 0


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50699&edit=1



Thread (5 messages)

« previous php.bugs (#146455) next »