From c81ad1d52eb59734cda54112b6ad1a725e4b398e Mon Sep 17 00:00:00 2001 From: Mauro Altamura Date: Fri, 15 Oct 2021 10:23:53 +0200 Subject: [PATCH] Added exception in case of curl error --- src/Alexsoft/Curl.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Alexsoft/Curl.php b/src/Alexsoft/Curl.php index 45c498d..8d3abe8 100644 --- a/src/Alexsoft/Curl.php +++ b/src/Alexsoft/Curl.php @@ -166,6 +166,7 @@ function __call($name, $arguments) /** * @param $method string method of query * @return array|NULL + * @throws \Exception */ protected function request($method) { @@ -173,6 +174,9 @@ protected function request($method) $this->method = $method; $this->prepareRequest(); $this->response = curl_exec($this->resource); + if ($this->response === false) { + throw new \Exception(curl_error($this->resource)); + } curl_close($this->resource); return $this->parseResponse(); } @@ -283,4 +287,4 @@ protected function isValidUrl($value) { return filter_var($value, FILTER_VALIDATE_URL) !== false; } -} \ No newline at end of file +}