Browse Source

Get a Predis\ResponseError instance from a Predis\ServerException instance.

Daniele Alessandri 15 năm trước cách đây
mục cha
commit
fa22d9667c
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      lib/Predis.php

+ 7 - 2
lib/Predis.php

@@ -3,7 +3,12 @@ namespace Predis;
 
 class PredisException extends \Exception { }
 class ClientException extends PredisException { }                   // Client-side errors
-class ServerException extends PredisException { }                   // Server-side errors
+
+class ServerException extends PredisException {                     // Server-side errors
+    public function toResponseError() {
+        return new ResponseError($this->getMessage());
+    }
+}
 
 class CommunicationException extends PredisException {              // Communication errors
     private $_connection;
@@ -2280,4 +2285,4 @@ class Discard extends \Predis\InlineCommand {
     public function canBeHashed()  { return false; }
     public function getCommandId() { return 'DISCARD'; }
 }
-?>
+?>