Mohit Raj commited on
Commit
95e5aee
·
verified ·
1 Parent(s): d15e487

Sync from GitHub via hub-sync

Browse files
Files changed (1) hide show
  1. frontend_demo.html +5 -1
frontend_demo.html CHANGED
@@ -242,6 +242,10 @@
242
  body: JSON.stringify({ question: text })
243
  });
244
 
 
 
 
 
245
  const reader = response.body.getReader();
246
  const decoder = new TextDecoder();
247
  let isFirstChunk = true;
@@ -286,7 +290,7 @@
286
 
287
  } catch (error) {
288
  console.error("Error:", error);
289
- aiMsg.innerHTML = "Sorry, I ran into an error. Please try again!";
290
  }
291
  history.scrollTop = history.scrollHeight;
292
  }
 
242
  body: JSON.stringify({ question: text })
243
  });
244
 
245
+ if (!response.ok) {
246
+ throw new Error(response.status === 404 ? "Server URL is incorrect" : "Server is currently sleeping");
247
+ }
248
+
249
  const reader = response.body.getReader();
250
  const decoder = new TextDecoder();
251
  let isFirstChunk = true;
 
290
 
291
  } catch (error) {
292
  console.error("Error:", error);
293
+ aiMsg.innerHTML = "⚠️ **AI Mentor is currently offline.**<br><br>The server is taking a break or is restarting. Please wait 1 minute and refresh! 📚☕";
294
  }
295
  history.scrollTop = history.scrollHeight;
296
  }