コード例 #1
0
 /**
  * @param \Google_Service_Exception $e
  * @param string                    $resourceName
  *
  * @return bool
  */
 private function _isAlreadyExistsError(\Google_Service_Exception $e, $resourceName)
 {
     return $e->getCode() == 409 && stristr($e->getMessage(), 'Resource already exists in the project (resource=' . basename($resourceName) . ')');
 }
コード例 #2
0
ファイル: BigQueryHelper.php プロジェクト: packaged/bigquery
 /**
  * Handle errors from inserts - create missing datasets and tables if
  * required and return the appropriate error state
  *
  * @param string|\Google_Service_Exception $errorMsg
  * @param IBigQueryWriteable[]             $data
  *
  * @return int
  */
 protected function _handleTableError($errorMsg, array $data)
 {
     $result = self::ERR_UNKNOWN;
     if ($errorMsg instanceof \Google_Service_Exception) {
         if ($errorMsg->allowedRetries() == 0) {
             $result = self::ERR_FATAL;
         }
     } else {
         /** @var IBigQueryWriteable $firstObj */
         $firstObj = reset($data);
         try {
             if (stristr($errorMsg, 'Not found: Dataset')) {
                 $this->createDataset();
                 $this->createTableForObject($firstObj);
                 $result = self::ERR_DELAYED_RETRY;
             } else {
                 if (stristr($errorMsg, 'Not found: Table')) {
                     $this->createTableForObject($firstObj);
                     $result = self::ERR_DELAYED_RETRY;
                 }
             }
         } catch (\Exception $e) {
             $this->_debug("ERROR: (" . $e->getCode() . ") " . $e->getMessage() . "\n" . $e->getTraceAsString());
             $result = self::ERR_FATAL;
         }
     }
     return $result;
 }