show retryable source outage guidance
This commit is contained in:
@@ -23,8 +23,11 @@ export async function fetchTenderDetail(tenderId, {signal, timeoutMs = 30000} =
|
||||
const searchResult=String(tenderId).startsWith('ekap-');
|
||||
const url=searchResult ? `/api/documents/ilan?ikn=${encodeURIComponent(tenderId.slice(5))}` : `/api/tenders/${encodeURIComponent(tenderId)}/detail`;
|
||||
const res = await fetch(url, {signal:controller.signal});
|
||||
if (!res.ok) throw new Error(`Detay API hatası: HTTP ${res.status}`);
|
||||
const data = await res.json();
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
if (data.code === 'SOURCE_UNAVAILABLE' && data.retryable) throw new Error('Resmi ihale kaynağı geçici olarak erişilemiyor. Birkaç dakika sonra yeniden deneyin.');
|
||||
throw new Error(`Detay API hatası: HTTP ${res.status}`);
|
||||
}
|
||||
if (!data.success) throw new Error(data.error || 'Detay alınamadı');
|
||||
if (searchResult) {
|
||||
if (data.ikn !== tenderId.slice(5)) throw new Error('Kaynak yanıtındaki İKN aranan ihaleyle uyuşmuyor.');
|
||||
|
||||
Reference in New Issue
Block a user