YouTube Analytics API 오류 처리추가
This commit is contained in:
1 parent
5b6fab8ef4
commit
7c3c0b4508
4 files changed
+13
-39
No files matched your search
@@ -480,6 +480,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [error, setError] = useState<DashboardError | null>(null);
|
||||
const [showMockData, setShowMockData] = useState(false);
|
||||
const [retryTrigger, setRetryTrigger] = useState(0);
|
||||
|
||||
// 계정 관련 state
|
||||
const [accounts, setAccounts] = useState<ConnectedAccount[]>([]);
|
||||
@@ -576,7 +577,8 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
setDashboardData(null);
|
||||
return;
|
||||
}
|
||||
throw new Error(errorData.detail || `API Error: ${response.status}`);
|
||||
setError({ code: errorData.code || 'API_ERROR', message: errorData.detail || `API Error: ${response.status}`, reconnect_url: errorData.reconnect_url });
|
||||
return;
|
||||
}
|
||||
|
||||
const data: DashboardResponse = await response.json();
|
||||
@@ -591,7 +593,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
console.error('Dashboard API Error:', err);
|
||||
setError(err instanceof Error ? err.message : 'Unknown error');
|
||||
setError({ code: 'UNKNOWN', message: err instanceof Error ? err.message : 'Unknown error' });
|
||||
setDashboardData(null);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
@@ -599,7 +601,7 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
};
|
||||
|
||||
fetchDashboardData();
|
||||
}, [mode, selectedAccountId, accountsLoaded]);
|
||||
}, [mode, selectedAccountId, accountsLoaded, retryTrigger]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -688,6 +690,14 @@ const DashboardContent: React.FC<DashboardContentProps> = ({ onNavigate }) => {
|
||||
연동하러 가기 →
|
||||
</button>
|
||||
)}
|
||||
{(error.code === 'YOUTUBE_API_FAILED' || error.code === 'DASHBOARD_DATA_ERROR') && (
|
||||
<button
|
||||
onClick={() => { setError(null); setRetryTrigger((n: number) => n + 1); }}
|
||||
className="ml-4 px-4 py-2 bg-yellow-600 text-white rounded hover:bg-yellow-700 whitespace-nowrap"
|
||||
>
|
||||
재시도 →
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user