PEAR_ErrorStack and exception in PHP5

From: Date: Sun, 24 Oct 2004 08:24:47 +0000
Subject: PEAR_ErrorStack and exception in PHP5
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15071@lists.php.net to get a copy of this message
I don't get it correct. I am having an error saying 'Debug Error: E:\Source\CMAES\src\include\cmaes_smarty.inc.php line 266 - Can only throw objects' According to the docs, in the call to PEAR_ErrorStack::singleton you can set which Exceptionclass you want to "throw" in PHP5 Example: $oErrorStack =& PEAR_ErrorStack::singleton("MyPackage", false, false, false, 'Exception'); When you want to throw an exception you can do like this: throw ($oErrorStack->push(MY_ERROR_CODE, 'error', array('username' => 'grob'))); And here comes my problem. The push method does not return a class derived from Exception? It returns the error array instead. What am I doing wrong? The code in the end pf the push method in ErrorStack.php look likes as follows. if ($this->_compat && $push) { return $this->raiseError($msg, $code, null, null, $err); } if (class_exists($this->_exceptionClass)) { $exception = $this->_exceptionClass; $ret = new $exception($msg, $code); $ret->errorData = $err; } return $err; Should it not look like this? if ($this->_compat && $push) { return $this->raiseError($msg, $code, null, null, $err); } if (class_exists($this->_exceptionClass)) { $exception = $this->_exceptionClass; $ret = new $exception($msg, $code); $ret->errorData = $err; return $ret; } return $err; /Erik

« previous php.pear.general (#15071) next »