Skip to content

Commit

Permalink
fix: Make supportedApps legacy interface compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
keriati committed Nov 29, 2022
1 parent bb5a078 commit 6dead1c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/SupportedApps.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -76,24 +78,25 @@ public function execute(
): ?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();
}
Expand Down

0 comments on commit 6dead1c

Please sign in to comment.