Re: PEAR_ErrorStack and exception in PHP5
| From: | Greg Beaver | Date: | Sun, 24 Oct 2004 13:29:06 +0000 |
| Subject: | Re: PEAR_ErrorStack and exception in PHP5 | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15072@lists.php.net to get a copy of this message | ||
Erik franzén wrote:
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;Yes. However, I've decided that generically instantiating an exception does not really make sense, as you can do: $err = $stack->push(...); throw new MySpecialException(....); as opposed to the problems I've run into: 1) exception error codes can only be integers, so you hvae to typecast the code to an integer 2) you can't pass anything but a message and a code by default, so I have to assign the error data "magically" which is bad OO practice. So, in the next version (due out very soon) returning an exception is completely disabled, it only returns an array or PEAR_Error depending on the compatibility mode. Greg