Changes
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Services\Vicon\DirectionStudy;
|
namespace App\Services\Vicon\DirectionStudy;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class DirectionStudyService
|
class DirectionStudyService
|
||||||
{
|
{
|
||||||
@@ -72,10 +73,17 @@ class DirectionStudyService
|
|||||||
try {
|
try {
|
||||||
$response = Http::withToken($token)->get($endpoint);
|
$response = Http::withToken($token)->get($endpoint);
|
||||||
$data = $response->object();
|
$data = $response->object();
|
||||||
|
|
||||||
|
// Проверяем наличие сообщения об ошибке в ответе
|
||||||
|
if (isset($data->message)) {
|
||||||
|
throw new \Exception($data->message);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Ошибка при вызове API: ' . $e->getMessage());
|
Log::error('Ошибка при вызове API: ' . $e->getMessage());
|
||||||
throw $e;
|
throw $e; // Перебрасываем исключение
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -37,15 +37,21 @@ class EducationalProgramService
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function callAPI(string $endpoint, string $token = null) : object|array
|
private function callAPI(string $endpoint, string $token = null): object
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = Http::withToken($token)->get($endpoint);
|
$response = Http::withToken($token)->get($endpoint);
|
||||||
$data = $response->object();
|
$data = $response->object();
|
||||||
|
|
||||||
|
// Проверяем наличие сообщения об ошибке в ответе
|
||||||
|
if (isset($data->message)) {
|
||||||
|
throw new \Exception($data->message);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('Ошибка при вызове API: ' . $e->getMessage());
|
Log::error('Ошибка при вызове API: ' . $e->getMessage());
|
||||||
throw $e;
|
throw $e; // Перебрасываем исключение
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user