From ff85e1c993da9b95a75db62645a747ae681b1306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sun, 15 Feb 2026 17:44:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:AI=20=EB=B6=84=EC=84=9D=20504=20=ED=83=80?= =?UTF-8?q?=EC=9E=84=EC=95=84=EC=9B=83=20=EC=97=90=EB=9F=AC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Controller: analyzeScreenshots()를 try-catch로 감싸 JSON 에러 응답 보장 - Frontend: api() 함수에서 HTML 응답(504/502 등) 감지 → 친절한 한글 에러 메시지 표시 Co-Authored-By: Claude Opus 4.6 --- .../Controllers/Video/TutorialVideoController.php | 13 ++++++++++++- resources/views/video/tutorial/index.blade.php | 11 ++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Video/TutorialVideoController.php b/app/Http/Controllers/Video/TutorialVideoController.php index e87bb1b4..253af8d8 100644 --- a/app/Http/Controllers/Video/TutorialVideoController.php +++ b/app/Http/Controllers/Video/TutorialVideoController.php @@ -84,7 +84,18 @@ public function analyze(Request $request): JsonResponse } } - $analysisData = $this->screenAnalysisService->analyzeScreenshots($paths); + try { + $analysisData = $this->screenAnalysisService->analyzeScreenshots($paths); + } catch (\Exception $e) { + \Illuminate\Support\Facades\Log::error('TutorialVideoController: 분석 예외', [ + 'error' => $e->getMessage(), + ]); + + return response()->json([ + 'success' => false, + 'message' => 'AI 분석 중 오류가 발생했습니다: ' . $e->getMessage(), + ], 500); + } if (empty($analysisData)) { return response()->json([ diff --git a/resources/views/video/tutorial/index.blade.php b/resources/views/video/tutorial/index.blade.php index 811d3d7d..b63a7fb8 100644 --- a/resources/views/video/tutorial/index.blade.php +++ b/resources/views/video/tutorial/index.blade.php @@ -107,7 +107,16 @@ headers['Content-Type'] = 'application/json'; } return fetch(url, { headers, ...options }).then(async (res) => { - const data = await res.json(); + const text = await res.text(); + let data; + try { + data = JSON.parse(text); + } catch { + // HTML 에러 페이지 반환 시 (504 Gateway Timeout 등) + if (res.status === 504) throw new Error('서버 응답 시간 초과 (504). AI 분석에 시간이 오래 걸리고 있습니다. 잠시 후 다시 시도해주세요.'); + if (res.status === 502) throw new Error('서버 연결 오류 (502). 잠시 후 다시 시도해주세요.'); + throw new Error(`서버 오류 (HTTP ${res.status}). 잠시 후 다시 시도해주세요.`); + } if (!res.ok) throw new Error(data.message || `HTTP ${res.status}`); return data; });