summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas V.V.Cox <cox@php.net>2001-07-29 04:25:33 +0000
committerTomas V.V.Cox <cox@php.net>2001-07-29 04:25:33 +0000
commit1e2d51855c1fc7995fa3fb9892827433fe66a57c (patch)
treee24b4bb9de5e82182bd1cbc2b7dcdd7bf3e5275d
parentfa75ae3394bc2d70f76fb4f10371a74207cb29e9 (diff)
downloadphp-git-1e2d51855c1fc7995fa3fb9892827433fe66a57c.tar.gz
raiseError() now can accepts a PEAR error object in its first argument. With
this, users can "re-throw" a previously created PEAR error object (very useful after the use of (push|pop)ErrorHandling)
-rw-r--r--pear/PEAR.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/pear/PEAR.php b/pear/PEAR.php
index 477f2d9c13..a98c04e60f 100644
--- a/pear/PEAR.php
+++ b/pear/PEAR.php
@@ -224,7 +224,7 @@ class PEAR
* handling applied. If the $mode and $options parameters are not
* specified, the object's defaults are used.
*
- * @param $message a text error message
+ * @param $message a text error message or a PEAR error object
* @param $code a numeric error code (it is up to your class
* to define these if you want to use codes)
* @param $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
@@ -260,6 +260,14 @@ class PEAR
$error_class = null,
$skipmsg = false)
{
+ // The error is yet a PEAR error object
+ if (is_object($message)) {
+ $code = $message->getCode();
+ $userinfo = $message->getUserInfo();
+ $error_class = $message->getType();
+ $message = $message->getMessage();
+ }
+
if ($mode === null) {
if (isset($this) && isset($this->_default_error_mode)) {
$mode = $this->_default_error_mode;
@@ -453,7 +461,7 @@ class PEAR_Error
$this->message = $message;
$this->code = $code;
$this->mode = $mode;
- $this->userinfo = $userinfo;
+ $this->userinfo = $userinfo;
if ($mode & PEAR_ERROR_CALLBACK) {
$this->level = E_USER_NOTICE;
$this->callback = $options;