@@ -62,6 +62,12 @@ private function initExpressions() {
62
62
$ this ->activeExpression = "#ACTIVE# " ;
63
63
}
64
64
65
+ private function getSingleLine () {
66
+ $ pos = strpos ($ this ->readBuffer , "\r\n" );
67
+ $ return = substr ($ this ->readBuffer , 0 , $ pos );
68
+ return [$ return , $ pos ];
69
+ }
70
+
65
71
/**
66
72
* Read line from the server
67
73
*
@@ -75,8 +81,7 @@ private function readLine() {
75
81
while (true ) {
76
82
try {
77
83
if ($ this ->readBuffer != null ) {
78
- $ pos = strpos ($ this ->readBuffer , "\r\n" );
79
- $ return = substr ($ this ->readBuffer , 0 , $ pos );
84
+ list ($ return , $ pos ) = $ this ->getSingleLine ();
80
85
$ this ->readBuffer = substr ($ this ->readBuffer , $ pos + strlen ("\r\n" ));
81
86
break ;
82
87
}
@@ -172,7 +177,13 @@ private function parseError($text) {
172
177
preg_match ($ this ->sizeExpression , $ text , $ matches );
173
178
if ($ matches ) {
174
179
$ this ->errorCode = "" ;
175
- $ this ->errorMessage = $ this ->readBlock ($ matches [1 ] + 2 );
180
+ $ errorMessage = $ matches [1 ] + 2 ;
181
+ list ($ nextLine , $ _ ) = $ this ->getSingleLine ();
182
+ if (preg_match ('/^\d+$/ ' , trim ($ errorMessage )) && preg_match ('/error:/i ' , $ nextLine )) {
183
+ $ this ->errorMessage = $ nextLine ;
184
+ } else {
185
+ $ this ->errorMessage = $ this ->readBlock ($ errorMessage );
186
+ }
176
187
return ;
177
188
}
178
189
0 commit comments