Use "throw new Exception"

pull/2487/head
Julio 9 years ago
parent e8551d5606
commit 7d8d209ad1
  1. 16
      main/inc/lib/pear/HTML/QuickForm.php
  2. 2
      main/inc/lib/pear/PEAR.php

@ -1105,6 +1105,8 @@ class HTML_QuickForm extends HTML_Common
) { ) {
if (!$force) { if (!$force) {
if (!is_array($element) && !$this->elementExists($element)) { if (!is_array($element) && !$this->elementExists($element)) {
throw new Exception( "Element '$element' does not exist in HTML_QuickForm::addRule()");
/*
return PEAR::raiseError( return PEAR::raiseError(
null, null,
QUICKFORM_NONEXIST_ELEMENT, QUICKFORM_NONEXIST_ELEMENT,
@ -1113,11 +1115,13 @@ class HTML_QuickForm extends HTML_Common
"Element '$element' does not exist in HTML_QuickForm::addRule()", "Element '$element' does not exist in HTML_QuickForm::addRule()",
'HTML_QuickForm_Error', 'HTML_QuickForm_Error',
true true
); );*/
} elseif (is_array($element)) { } elseif (is_array($element)) {
foreach ($element as $el) { foreach ($element as $el) {
if (!$this->elementExists($el)) { if (!$this->elementExists($el)) {
return PEAR::raiseError( throw new Exception( "Element '$el' does not exist in HTML_QuickForm::addRule()");
/*return PEAR::raiseError(
null, null,
QUICKFORM_NONEXIST_ELEMENT, QUICKFORM_NONEXIST_ELEMENT,
null, null,
@ -1125,12 +1129,16 @@ class HTML_QuickForm extends HTML_Common
"Element '$el' does not exist in HTML_QuickForm::addRule()", "Element '$el' does not exist in HTML_QuickForm::addRule()",
'HTML_QuickForm_Error', 'HTML_QuickForm_Error',
true true
); );*/
} }
} }
} }
} }
if (false === ($newName = $this->isRuleRegistered($type, true))) { if (false === ($newName = $this->isRuleRegistered($type, true))) {
throw new Exception("Rule '$type' is not registered in HTML_QuickForm::addRule()");
/*
return PEAR::raiseError( return PEAR::raiseError(
null, null,
QUICKFORM_INVALID_RULE, QUICKFORM_INVALID_RULE,
@ -1139,7 +1147,7 @@ class HTML_QuickForm extends HTML_Common
"Rule '$type' is not registered in HTML_QuickForm::addRule()", "Rule '$type' is not registered in HTML_QuickForm::addRule()",
'HTML_QuickForm_Error', 'HTML_QuickForm_Error',
true true
); );*/
} elseif (is_string($newName)) { } elseif (is_string($newName)) {
$type = $newName; $type = $newName;
} }

@ -508,7 +508,7 @@ class PEAR
* @see PEAR::setErrorHandling * @see PEAR::setErrorHandling
* @since PHP 4.0.5 * @since PHP 4.0.5
*/ */
function &raiseError($message = null, public static function &raiseError($message = null,
$code = null, $code = null,
$mode = null, $mode = null,
$options = null, $options = null,

Loading…
Cancel
Save