ZF-7102: Exception not propogated correctly if thrown from constructor
Description
Consider a PHP Class with the following constructor:
public function __construct() {
$this->connection = mysql_connect($this->server, $this->username, $this->password);
if(mysql_error()) {
$msg = mysql_errno() . ": " . mysql_error();
throw new Exception('MySQL Error - '. $msg);
}
mysql_select_db($this->databasename);
}
when an exception is thrown, Zend AMF ignores it and throws an exception with the message "Error instantiating class"
try {
$object = $info->getDeclaringClass()->newInstance();
} catch (Exception $e) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName(), 621);
}
While throwing this exception, ZendAMF should append the error message from the caught exception.
Comments
Posted by Stanislav Malyshev (stas) on 2009-06-30T17:26:17.000+0000
fixed