handleCurlError($url, $err, $message); } if (curl_getinfo($handle, CURLINFO_HTTP_CODE) !== self::HTTP_OK) { $err = curl_errno($handle); // extract all the error codes from Amazon $error_code = json_decode($result)->errorCode; $error_type = json_decode($result)->errorType; $message = json_decode($result)->message; throw AmazonErrors::getError( $error_code, $error_type, $message, $err ); } return $result; } /** * Undocumented function * * @param string $url * @param string $errno * @param string $message * @return void */ private function handleCurlError(string $url, int $errno, string $message): void { switch ($errno) { case CURLE_COULDNT_CONNECT: case CURLE_COULDNT_RESOLVE_HOST: case CURLE_OPERATION_TIMEOUTED: $msg = 'Could not connect to AWS (' . $url . '). Please check your ' . 'internet connection and try again.'; break; case CURLE_SSL_CACERT: case CURLE_SSL_PEER_CERTIFICATE: $msg = 'Could not verify AWS SSL certificate. Please make sure ' . 'that your network is not intercepting certificates. ' . '(Try going to ' . $url . 'in your browser.) ' . 'If this problem persists,'; break; case 0: default: $msg = 'Unexpected error communicating with AWS. ' . $message; } throw new \RuntimeException($msg); } } // __END__