diff --git a/src/Exceptions/ErrorException.php b/src/Exceptions/ErrorException.php index 9194353..59f7538 100644 --- a/src/Exceptions/ErrorException.php +++ b/src/Exceptions/ErrorException.php @@ -22,4 +22,9 @@ public static function snimoeValueNotFound(): self { return new self("SNlM0e value not found in response. Check __Secure-1PSID value."); } + + public static function curlError($error): self + { + return new self("Curl error: " . $error); + } } diff --git a/src/LaravelBard.php b/src/LaravelBard.php index 47cc73c..7bd1830 100644 --- a/src/LaravelBard.php +++ b/src/LaravelBard.php @@ -25,7 +25,7 @@ class LaravelBard private $reqid; private $SNlM0e; - public function __construct($timeout = 6, $proxies = null, $session = null) + public function __construct($timeout = 60, $proxies = null, $session = null) { $this->proxies = $proxies; $this->timeout = $timeout; @@ -120,6 +120,11 @@ public function get_answer($input_text) ]); $resp = curl_exec($this->session); + + if (curl_errno($this->session)) { + throw ErrorException::curlError(curl_error($this->session)); + } + $resp_dict = json_decode(explode("\n", $resp)[3], true)[0][2]; if ($resp_dict === null) {