From 6dead1c529a0cc7e0f9ea0717cfb09b68e1ff455 Mon Sep 17 00:00:00 2001 From: Attila Kerekes Date: Tue, 29 Nov 2022 19:47:58 +0100 Subject: [PATCH] fix: Make supportedApps legacy interface compatible --- app/SupportedApps.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/SupportedApps.php b/app/SupportedApps.php index bafb4af2..c2798230 100644 --- a/app/SupportedApps.php +++ b/app/SupportedApps.php @@ -3,7 +3,9 @@ namespace App; use GuzzleHttp\Client; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\GuzzleException; +use GuzzleHttp\Exception\ServerException; use Illuminate\Support\Facades\Log; use Psr\Http\Message\ResponseInterface; @@ -76,24 +78,25 @@ abstract class SupportedApps ): ?ResponseInterface { $res = null; - $vars = ($overridevars !== null || $overridevars !== false) ? - $overridevars : [ + $vars = ($overridevars === null || $overridevars === false) ? + [ 'http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15, - ]; + ] : $overridevars; $client = new Client($vars); - $method = ($overridemethod !== null || $overridemethod !== false) ? $overridemethod : $this->method; + $method = ($overridemethod === null || $overridemethod === false) ? $this->method : $overridemethod; + try { return $client->request($method, $url, $attrs); - } catch (\GuzzleHttp\Exception\ConnectException $e) { + } catch (ConnectException $e) { Log::error('Connection refused'); Log::debug($e->getMessage()); $this->error = 'Connection refused - '.(string) $e->getMessage(); - } catch (\GuzzleHttp\Exception\ServerException $e) { + } catch (ServerException $e) { Log::debug($e->getMessage()); $this->error = (string) $e->getResponse()->getBody(); }