diff --git a/Speed/Convoy.php b/Speed/Convoy.php index a215363..4143e98 100644 --- a/Speed/Convoy.php +++ b/Speed/Convoy.php @@ -22,7 +22,11 @@ class Convoy extends Server if (!$response->successful()) { $json = $response->json(); - $message = $json['message'] ?? $json['error'] ?? 'Server Error'; + if (is_array($json)) { + $message = $json['message'] ?? $json['error'] ?? $json['errors'][0]['message'] ?? 'Server Error'; + } else { + $message = 'Server Error: ' . $response->status(); + } throw new Exception($message); } @@ -30,7 +34,7 @@ class Convoy extends Server } /** - * Get all the configuration for the extension + * Get all configuration for extension * * @param array $values */ @@ -150,10 +154,10 @@ class Convoy extends Server $os = $this->request('nodes/' . $node . '/template-groups'); $options = []; - foreach ($os['data'] as $os) { - foreach ($os['templates'] as $template) { - foreach ($template as $template1) { - $options[$template1['uuid']] = $template1['name']; + foreach ($os['data'] as $osGroup) { + foreach ($osGroup['templates'] as $templateGroup) { + foreach ($templateGroup as $template) { + $options[$template['uuid']] = $template['name']; } } } @@ -178,7 +182,7 @@ class Convoy extends Server } /** - * Check if currenct configuration is valid + * Check if current configuration is valid */ public function testConfig(): bool|string { @@ -193,7 +197,7 @@ class Convoy extends Server return true; } - // Convoy is reallyy strict (The account password must contain 8 - 50 characters, 1 uppercase, 1 lowercase, 1 number and 1 special character.) + // Convoy is really strict (The account password must contain 8 - 50 characters, 1 uppercase, 1 lowercase, 1 number and 1 special character.) private function createPassword() { $password = Str::password(); @@ -432,4 +436,4 @@ class Convoy extends Server return rtrim($this->config('host'), '/') . '/authenticate?token=' . $data['data']['token']; } -} +} \ No newline at end of file