@@ -831,7 +831,7 @@ public function getProtocol()
831831 protected function executeFailableOperation ($ method , ...$ args )
832832 {
833833 set_error_handler (function ($ severity , $ message , $ file , $ line ) {
834- if (!$ this ->causedBySizeLimit ($ message )) {
834+ if (!$ this ->shouldBypassError ($ message )) {
835835 throw new ErrorException ($ message , $ severity , $ severity , $ file , $ line );
836836 }
837837 });
@@ -846,15 +846,58 @@ protected function executeFailableOperation($method, ...$args)
846846 }
847847
848848 /**
849- * Determine if the given error message was a size limit warning.
849+ * Determine if the error should be bypassed.
850+ *
851+ * @param string $error
852+ *
853+ * @return bool
854+ */
855+ protected function shouldBypassError ($ error )
856+ {
857+ return $ this ->causedByPaginationSupport ($ error ) || $ this ->causedBySizeLimit ($ error );
858+ }
859+
860+ /**
861+ * Determine if the error was caused by lack of pagination support.
862+ *
863+ * @param string $error
864+ *
865+ * @return bool
866+ */
867+ protected function causedByPaginationSupport ($ error )
868+ {
869+ return $ this ->errorContainsMessage ($ error , 'No server controls in result ' );
870+ }
871+
872+ /**
873+ * Determine if the error was caused by a size limit warning.
850874 *
851875 * @param $error
852876 *
853877 * @return bool
854878 */
855879 protected function causedBySizeLimit ($ error )
856880 {
857- return strpos ($ error , 'Partial search results returned ' ) !== false ;
881+ return $ this ->errorContainsMessage ($ error , ['Partial search results returned ' , 'Size limit exceeded ' ]);
882+ }
883+
884+ /**
885+ * Determine if the given error contains the any of the messages.
886+ *
887+ * @param string $error
888+ * @param string|array $messages
889+ *
890+ * @return bool
891+ */
892+ protected function errorContainsMessage ($ error , $ messages = [])
893+ {
894+ foreach ((array ) $ messages as $ message ) {
895+ if (strpos ($ error , $ message ) !== false ) {
896+ return true ;
897+ }
898+ }
899+
900+ return false ;
858901 }
859902
860903 /**
0 commit comments