This commit is contained in:
f4ilji
2024-12-24 19:25:16 +05:00
parent ed7ac493a0
commit 700bf98de6
2 changed files with 17 additions and 3 deletions
@@ -37,15 +37,21 @@ class EducationalProgramService
return $data;
}
private function callAPI(string $endpoint, string $token = null) : object|array
private function callAPI(string $endpoint, string $token = null): object
{
try {
$response = Http::withToken($token)->get($endpoint);
$data = $response->object();
// Проверяем наличие сообщения об ошибке в ответе
if (isset($data->message)) {
throw new \Exception($data->message);
}
return $data;
} catch (\Exception $e) {
Log::error('Ошибка при вызове API: ' . $e->getMessage());
throw $e;
throw $e; // Перебрасываем исключение
}
}