Exemplo n.º 1
0
 /**
  * @dataProvider exceptionProvider
  *
  * @param $exception
  * @param $code
  * @param $contains
  */
 public function testExceptions($exception, $code, $contains)
 {
     $formed = CqlException::from($exception);
     $this->assertInstanceOf('\\Packaged\\Dal\\Exceptions\\Connection\\CqlException', $formed);
     $this->assertEquals($code, $formed->getCode());
     if (is_array($contains)) {
         foreach ($contains as $contain) {
             $this->assertContains($contain, $formed->getMessage());
         }
     } else {
         $this->assertContains($contains, $formed->getMessage());
     }
     $this->assertSame($exception, $formed->getPrevious());
 }
Exemplo n.º 2
0
 /**
  * @param CqlException $e
  *
  * @return bool
  */
 private function _isRecoverableException(CqlException $e)
 {
     if ($e->getPrevious() instanceof TTransportException || Strings::startsWith($e->getMessage(), 'TSocketPool: All hosts in pool are down.')) {
         $this->_removeCurrentHost();
         return true;
     }
     if ($e->getPrevious() instanceof InvalidRequestException && Strings::startsWith($e->getMessage(), 'Prepared query with ID')) {
         return true;
     }
     if ($this->_strictRecoverable || $e->getPrevious() instanceof NotFoundException || $e->getPrevious() instanceof InvalidRequestException) {
         return false;
     }
     error_log('Exception As Recoverable: (' . $e->getCode() . ') ' . $e->getMessage());
     return true;
 }