public function curlExceptionProvider() { $requestException = new RequestException('request'); $requestException->setRequest(new Request('GET', '/')); $curlException = new CurlException('curl'); $curlException->setRequest(new Request('GET', '/')); return array( array($curlException, '\FOS\HttpCache\Exception\ProxyUnreachableException'), array($requestException, '\FOS\HttpCache\Exception\ProxyResponseException'), array(new \InvalidArgumentException('something'), '\InvalidArgumentException'), ); }
/** * Check if a cURL transfer resulted in what should be an exception * * @param RequestInterface $request Request to check * @param CurlHandle $handle Curl handle object * @param array $curl Curl message returned from curl_multi_info_read * * @return Exception|bool */ private function isCurlException(RequestInterface $request, CurlHandle $handle, array $curl) { if (CURLE_OK == $curl['result']) { return false; } $handle->setErrorNo($curl['result']); $e = new CurlException(sprintf('[curl] %s: %s [url] %s [info] %s [debug] %s', $handle->getErrorNo(), $handle->getError(), $handle->getUrl(), var_export($handle->getInfo(), true), $handle->getStderr())); $e->setRequest($request)->setError($handle->getError(), $handle->getErrorNo()); return $e; }