/** * @param CurlException $e * @return StorageApiEvent */ public function curlError(CurlException $e) { $event = $this->prepareEvent(); $event->setMessage(sprintf(self::MESSAGE_END, $this->task->getRunUrl()))->setDescription($e->getError())->setType(StorageApiEvent::TYPE_WARN)->setResults(array('response' => $e->getError(), 'code' => $e->getErrorNo())); $this->save($event); return $event; }
/** * curl error * @param \Guzzle\Common\Event $event * @throws KintoneException */ public function onRequestException(Event $event) { $this->request = $event->offsetGet('request'); $this->response = $event->offsetGet('response'); $this->exception = $event->offsetGet('exception'); if ($this->exception instanceof \Guzzle\Http\Exception\CurlException) { $errorNumber = $this->exception->getErrorNo(); switch ($errorNumber) { case 6: throw new KintoneException('kintone.unknown_url'); case 35: throw new KintoneException('kintone.invalid_cert'); default: throw new KintoneException('kintone.invalid_auth'); } } throw new \Exception($this->exception->getMessage()); }
public function testStoresCurlError() { $e = new CurlException(); $this->assertNull($e->getError()); $this->assertNull($e->getErrorNo()); $this->assertSame($e, $e->setError('test', 12)); $this->assertEquals('test', $e->getError()); $this->assertEquals(12, $e->getErrorNo()); }
public function testStoresCurlError() { $e = new CurlException(); $this->assertNull($e->getError()); $this->assertNull($e->getErrorNo()); $this->assertSame($e, $e->setError('test', 12)); $this->assertEquals('test', $e->getError()); $this->assertEquals(12, $e->getErrorNo()); $handle = new CurlHandle(curl_init(), array()); $e->setCurlHandle($handle); $this->assertSame($handle, $e->getCurlHandle()); $handle->close(); }
/** * @param CurlException $exception\ */ private function processCurlError(CurlException $exception) { $error = 'Curl error: ' . $exception->getMessage(); $this->log->error($error); $this->throwCurlException($exception->getErrorNo(), $exception->getError()); }