浏览代码

Svelte: Restore printing CX init error messages to the visible console

Alessandro Pignotti 9 月之前
父节点
当前提交
0a9a044b27
共有 2 个文件被更改,包括 15 次插入3 次删除
  1. 11 0
      src/lib/messages.js
  2. 4 3
      src/routes/+page.svelte

+ 11 - 0
src/lib/messages.js

@@ -1,3 +1,4 @@
+const color= "\x1b[1;35m";
 const underline= "\x1b[94;4m";
 const normal= "\x1b[0m";
 export const introMessage = [
@@ -25,5 +26,15 @@ export const introMessage = [
 	"     objdump -d ./helloworld | less -M",
 	"     vim examples/c/helloworld.c",
 	"     curl --max-time 15 parrot.live  # requires networking",
+	""
+];
+export const errorMessage = [
+	color + "CheerpX could not start" + normal,
+	"",
+	"CheerpX is expected to work with recent desktop versions of Chrome, Edge, Firefox and Safari",
+	"",
+	"Give it a try from a desktop version / another browser!",
 	"",
+	"CheerpX internal error message is:",
+	""
 ];

+ 4 - 3
src/routes/+page.svelte

@@ -12,7 +12,7 @@
 	import '@fortawesome/fontawesome-free/css/all.min.css'
 	import { networkInterface, startLogin } from '$lib/network.js'
 	import { cpuActivity, diskActivity } from '$lib/activities.js'
-	import { introMessage } from '$lib/messages.js'
+	import { introMessage, errorMessage } from '$lib/messages.js'
 
 	var term = new Terminal({cursorBlink:true, convertEol:true, fontFamily:"monospace", fontWeight: 400, fontWeightBold: 700});
 	var cx = null;
@@ -124,8 +124,9 @@
 		}
 		catch(e)
 		{
-			// TODO: Print error message on console
-			throw e;
+			printMessage(errorMessage);
+			printMessage([e.toString()]);
+			return;
 		}
 		cx.registerCallback("cpuActivity", cpuCallback);
 		cx.registerCallback("diskActivity", hddCallback);