diff --git a/app/Services/Vicon/DirectionStudy/DirectionStudyService.php b/app/Services/Vicon/DirectionStudy/DirectionStudyService.php index 08809d2..f7f6dc3 100644 --- a/app/Services/Vicon/DirectionStudy/DirectionStudyService.php +++ b/app/Services/Vicon/DirectionStudy/DirectionStudyService.php @@ -3,6 +3,7 @@ namespace App\Services\Vicon\DirectionStudy; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Log; class DirectionStudyService { @@ -72,10 +73,17 @@ class DirectionStudyService 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; // Перебрасываем исключение } } + } \ No newline at end of file diff --git a/app/Services/Vicon/EducationalProgram/EducationalProgramService.php b/app/Services/Vicon/EducationalProgram/EducationalProgramService.php index 4b7fe6c..2f4d400 100644 --- a/app/Services/Vicon/EducationalProgram/EducationalProgramService.php +++ b/app/Services/Vicon/EducationalProgram/EducationalProgramService.php @@ -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; // Перебрасываем исключение } }