Code

Updated error handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Apr 2011 09:52:41 +0000 (09:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Apr 2011 09:52:41 +0000 (09:52 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20743 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_jsonRPC.inc

index 443d23e195daadbd25669d977bbd2b766cc2fd0d..a3a164e8354119e84faa1572b1d46e0fbb9a3d10 100644 (file)
@@ -121,21 +121,22 @@ class jsonRPC {
      */
     public function get_error()
     {
+        $error = "";
         if($this->lastStats['http_code'] != 200){
             $error = $this->getHttpStatusCodeMessage($this->lastStats['http_code']);
-            if(isset($this->lastResult['error']['error']) && is_array($this->lastResult['error']['error'])){
-                $err = $this->lastResult['error']['error'];
-                $message = call_user_func_array(sprintf,$err);
-                $error .= $message;
-            }elseif(isset($this->lastResult['error']['message'])){
-                $error .= ": ".$this->lastResult['error']['message']; 
-            }
-            return($error);
-        }else{
-            return(curl_error($this->curlHandler));
         }
+        if(isset($this->lastResult['error']['error']) && is_array($this->lastResult['error']['error'])){
+            $err = $this->lastResult['error']['error'];
+            $message = call_user_func_array(sprintf,$err);
+            $error .= $message;
+        }elseif(isset($this->lastResult['error']['message'])){
+            $error .= $this->lastResult['error']['message']; 
+        }
+        if($error){
+            return(trim($error, ": "));
+        }
+        return(curl_error($this->curlHandler));
     }
-
     
 
     /*! \brief      Returns TRUE if the last action was successfull else FALSE.
@@ -144,6 +145,7 @@ class jsonRPC {
     public function success()
     {
         return(curl_errno($this->curlHandler) == 0 && 
+                !isset($this->lastResult['error']) && 
                 isset($this->lastStats['http_code']) && 
                 $this->lastStats['http_code'] == 200);
     }