]> granicus.if.org Git - php/commitdiff
Make the error handling work again since the new internal command
authorTomas V.V.Cox <cox@php.net>
Sun, 26 May 2002 19:08:21 +0000 (19:08 +0000)
committerTomas V.V.Cox <cox@php.net>
Sun, 26 May 2002 19:08:21 +0000 (19:08 +0000)
structure

pear/PEAR/Command/Config.php

index f2d12b550d40b9fdc6fb57b8e432c02cfa1cd0ef..e4441bb97050395f354f24bedfa3f1947f17d663 100644 (file)
@@ -83,8 +83,7 @@ in.  The default layer is "user".
     {
         // $params[0] -> the layer
         if ($error = $this->_checkLayer(@$params[0])) {
-            $failmsg .= $error;
-            break;
+            return $this->raiseError($error);
         }
         $keys = $this->config->getKeys();
         sort($keys);
@@ -115,11 +114,10 @@ in.  The default layer is "user".
         // $params[0] -> the parameter
         // $params[1] -> the layer
         if ($error = $this->_checkLayer(@$params[1])) {
-            $failmsg .= $error;
-            break;
+            return $this->raiseError($error);
         }
         if (sizeof($params) < 1 || sizeof($params) > 2) {
-            $failmsg .= "config-get expects 1 or 2 parameters";
+            return $this->raiseError("config-get expects 1 or 2 parameters");
         } elseif (sizeof($params) == 1) {
             $this->ui->displayLine("$params[0] = " . $this->config->get($params[0]));
         } else {
@@ -135,20 +133,22 @@ in.  The default layer is "user".
         // $param[1] -> the value for the parameter
         // $param[2] -> the layer
         $failmsg = '';
-        if (sizeof($params) < 2 || sizeof($params) > 3) {
-            $failmsg .= "config-set expects 2 or 3 parameters";
-            break;
-        }
-        if ($error = $this->_checkLayer(@$params[2])) {
-            $failmsg .= $error;
-            break;
-        }
-        if (!call_user_func_array(array(&$this->config, 'set'), $params))
-        {
-            $failmsg = "config-set (" . implode(", ", $params) . ") failed";
-        } else {
-            $this->config->store();
-        }
+        do {
+            if (sizeof($params) < 2 || sizeof($params) > 3) {
+                $failmsg .= "config-set expects 2 or 3 parameters";
+                break;
+            }
+            if ($error = $this->_checkLayer(@$params[2])) {
+                $failmsg .= $error;
+                break;
+            }
+            if (!call_user_func_array(array(&$this->config, 'set'), $params))
+            {
+                $failmsg = "config-set (" . implode(", ", $params) . ") failed";
+            } else {
+                $this->config->store();
+            }
+        } while (false);
         if ($failmsg) {
             return $this->raiseError($failmsg);
         }