errmsg() public static method

Get the gloable error message.
public static errmsg ( ) : string
return string
Exemplo n.º 1
0
 private function doBatchRun($useHttps = true)
 {
     $batchQueue = $this->batchQueue[$useHttps ? 0 : 1];
     if (empty($batchQueue)) {
         return;
     }
     $num = count($batchQueue);
     $params = array();
     foreach ($batchQueue as $item) {
         $params[] = $item['i'];
     }
     $json = json_encode($params);
     $serialOnly = $this->batchMode === self::BATCH_MODE_SERIAL_ONLY;
     $params = array('method' => $json, 'serial_only' => $serialOnly);
     if ($useHttps) {
         $params['access_token'] = $this->getAccessToken();
         $domain = self::$BD_OPENAPI_DEFAULT_DOMAINS['rest'];
     } else {
         $params['client_id'] = $this->getClientId();
         $domain = self::$BD_OPENAPI_DEFAULT_DOMAINS['public'];
     }
     $result = BaiduUtils::request($domain . '/batch/run', $params, 'POST');
     if ($result === false) {
         throw new BaiduException('failed to call batch/run api: ' . BaiduUtils::errmsg(), BaiduUtils::errno());
     }
     $result = $this->converJson2Array($result);
     if (is_array($result) && isset($result['error_code'])) {
         throw new BaiduException('failed to call batch/run api: ' . $result['error_msg'], $result['error_code']);
     }
     for ($i = 0; $i < $num; $i++) {
         $item = $batchQueue[$i];
         $itemResult = $result[$i];
         if (is_array($itemResult) && isset($itemResult['error_code'])) {
             throw new BaiduException('failed to call ' . $item['i']['path'] . ' api: ' . $itemResult['error_msg'], $itemResult['error_code']);
         }
         $item['r'] = $itemResult;
     }
 }
Exemplo n.º 2
0
 /**
  * Set the gloable error number and error message.
  * 
  * @param int $errno Error code
  * @param string $errmsg Error message
  * @return void
  */
 public static function setError($errno, $errmsg)
 {
     self::$errno = $errno;
     self::$errmsg = $errmsg;
     self::errorLog($errmsg);
 }