Browse Source

* have DB.php use PEAR::raiseError in factory methods

PHP-4.0.6
Stig Bakken 25 years ago
parent
commit
2723ad2e63
  1. 10
      pear/DB.php
  2. 11
      pear/PEAR.php.in
  3. 10
      pear/tests/pear_error.phpt

10
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')));
}
/**

11
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);
}
}
// }}}

10
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>
Loading…
Cancel
Save