summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2001-04-17 01:51:27 +0000
committerStig Bakken <ssb@php.net>2001-04-17 01:51:27 +0000
commit2723ad2e63850863ac4228f2cdb96ba6347b5df2 (patch)
tree158828f7df82750793ec1decbe20ee4fe89a05b4
parent266cc59f06334bf956b2abfe70759c46ec6ebed5 (diff)
downloadphp-git-2723ad2e63850863ac4228f2cdb96ba6347b5df2.tar.gz
* have DB.php use PEAR::raiseError in factory methods
-rw-r--r--pear/DB.php10
-rw-r--r--pear/PEAR.php.in11
-rw-r--r--pear/tests/pear_error.phpt10
3 files changed, 20 insertions, 11 deletions
diff --git a/pear/DB.php b/pear/DB.php
index 462d0ece29..8dce9080e7 100644
--- a/pear/DB.php
+++ b/pear/DB.php
@@ -188,7 +188,8 @@ class DB
@$obj =& new $classname;
if (!$obj) {
- return new DB_Error(DB_ERROR_NOT_FOUND);
+ return PEAR::raiseError(DB_ERROR_NOT_FOUND,
+ null, null, null, null, 'DB_Error', true);
}
return $obj;
@@ -235,7 +236,8 @@ class DB
}
if (!$obj) {
- return new DB_Error(DB_ERROR_NOT_FOUND);
+ return PEAR::raiseError(DB_ERROR_NOT_FOUND,
+ null, null, null, null, 'DB_Error', true);
}
if (is_array($options)) {
@@ -278,8 +280,8 @@ class DB
function isError($value)
{
return (is_object($value) &&
- (get_class($value) == 'db_error' ||
- is_subclass_of($value, 'db_error')));
+ (get_class($value) == 'db_error' ||
+ is_subclass_of($value, 'db_error')));
}
/**
diff --git a/pear/PEAR.php.in b/pear/PEAR.php.in
index 529cd3dc3f..3c91b576d9 100644
--- a/pear/PEAR.php.in
+++ b/pear/PEAR.php.in
@@ -252,6 +252,9 @@ class PEAR
* @param $userinfo If you need to pass along for example debug
* information, this parameter is meant for that.
*
+ * @param $error_class The returned error object will be instantiated
+ * from this class, if specified.
+ *
* @return object a PEAR error object
*
* @see PEAR::setErrorHandling
@@ -261,7 +264,7 @@ class PEAR
function &raiseError($message = null, $code = null, $mode = null,
$options = null, $userinfo = null,
- $error_class = null)
+ $error_class = null, $skipmsg = false)
{
if ($mode === null) {
if (isset($this) && isset($this->_default_error_mode)) {
@@ -305,7 +308,11 @@ class PEAR
} else {
$ec = 'PEAR_Error';
}
- return new $ec($message, $code, $mode, $options, $userinfo);
+ if ($skipmsg) {
+ return new $ec($code, $mode, $options, $userinfo);
+ } else {
+ return new $ec($message, $code, $mode, $options, $userinfo);
+ }
}
// }}}
diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt
index 6b5ce87df6..3d1a9f2601 100644
--- a/pear/tests/pear_error.phpt
+++ b/pear/tests/pear_error.phpt
@@ -113,16 +113,16 @@ mode=print: test error[pear_error: message="test error" code=-42 mode=print leve
mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" prepend="" append="" info=""]
mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" prepend="" append="" info=""]
mode=print&trigger: test error<br>
-<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>399</b><br>
+<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
[pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" info=""]
mode=trigger: <br>
-<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>399</b><br>
+<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""]
mode=trigger,level=notice: <br>
-<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>399</b><br>
+<b>Notice</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""]
mode=trigger,level=warning: <br>
-<b>Warning</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>399</b><br>
+<b>Warning</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
[pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" info=""]
mode=trigger,level=error: <br>
-<b>Fatal error</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>399</b><br>
+<b>Fatal error</b>: test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>