فهرست منبع

Reuse code a bit.

Daniele Alessandri 14 سال پیش
والد
کامیت
306ed28c5d
1فایلهای تغییر یافته به همراه8 افزوده شده و 3 حذف شده
  1. 8 3
      lib/Predis.php

+ 8 - 3
lib/Predis.php

@@ -644,6 +644,7 @@ class ResponseReader {
     public function read(IConnectionSingle $connection) {
         $header = $connection->readLine();
         if ($header === '') {
+            $this->throwMalformedResponse('Unexpected empty header');
             Utils::onCommunicationException(new MalformedServerResponse(
                 $connection, 'Unexpected empty header'
             ));
@@ -651,13 +652,17 @@ class ResponseReader {
 
         $prefix  = $header[0];
         if (!isset($this->_prefixHandlers[$prefix])) {
-            Utils::onCommunicationException(new MalformedServerResponse(
-                $connection, "Unknown prefix '$prefix'"
-            ));
+            $this->throwMalformedResponse("Unknown prefix '$prefix'");
         }
         $handler = $this->_prefixHandlers[$prefix];
         return $handler->handle($connection, substr($header, 1));
     }
+
+    private function throwMalformedResponse($message) {
+        Utils::onCommunicationException(new MalformedServerResponse(
+            $connection, $message
+        ));
+    }
 }
 
 class ResponseError {