Changes
This commit is contained in:
@@ -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; // Перебрасываем исключение
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user