diff --git a/index.html b/index.html
index 66f741e..895bcf2 100644
--- a/index.html
+++ b/index.html
@@ -246,12 +246,23 @@
})
});
+ const status = response.status;
+ const statusText = response.statusText;
+
+ if (status === 404) {
+ throw new Error("Sunucu bulunamadı. Lütfen API adresini kontrol edin.");
+ } else if (status === 500) {
+ throw new Error("Sunucu hata verdi. Lütfen daha sonra tekrar deneyin.");
+ } else if (!response.ok) {
+ throw new Error(`HTTP hata: ${status} - ${statusText}`);
+ }
+
const data = await response.json();
rawDescription = data.response;
resultText.innerText = rawDescription;
document.getElementById('translateBtn').style.display = "block";
} catch (err) {
- resultText.innerText = "Hata: Sunucuya ulaşılamadı. Nginx veya Ollama ayarlarını kontrol edin.";
+ resultText.innerText = "Hata: Sunucuya ulaşılamadı. Nginx veya Ollama ayarlarını kontrol edin." + err.message;
console.error(err);
} finally {
btn.innerHTML = "Yeniden Analiz Et";
@@ -284,10 +295,22 @@
})
});
+ const status = response.status;
+ const statusText = response.statusText;
+
+ if (status === 404) {
+ throw new Error("Sunucu bulunamadı. Lütfen API adresini kontrol edin.");
+ } else if (status === 500) {
+ throw new Error("Sunucu hata verdi. Lütfen daha sonra tekrar deneyin.");
+ } else if (!response.ok) {
+ throw new Error(`HTTP hata: ${status} - ${statusText}`);
+ }
+
const data = await response.json();
trText.innerText = data.response;
} catch (err) {
- trText.innerText = "Hata: Çeviri servisi yanıt vermiyor.";
+ trText.innerText = "Hata: Çeviri servisi yanıt vermiyor." + err.message;
+ console.error(err);
} finally {
transBtn.disabled = false;
transBtn.innerHTML = "Türkçeye Çevir";