Browse Source

Catching theme error in editor, closes #43

Noah 7 years ago
parent
commit
17e8f7c27d
1 changed files with 19 additions and 2 deletions
  1. 19 2
      client/index.js

+ 19 - 2
client/index.js View File

@@ -6,8 +6,25 @@ var d3 = require("d3"),
6 6
 
7 7
 d3.json("/settings/themes.json", function(err, themes){
8 8
 
9
-  if (err) {
10
-    throw err;
9
+  var errorMessage;
10
+
11
+  // Themes are missing or invalid
12
+  if (err || !d3.keys(themes).filter(function(d){ return d !== "default"; }).length) {
13
+    if (err instanceof SyntaxError) {
14
+      errorMessage = "Error in settings/themes.json:<br/><code>" + err.toString() + "</code>";
15
+    } else if (err instanceof ProgressEvent) {
16
+      errorMessage = "Error: no settings/themes.json.";
17
+    } else if (err) {
18
+      errorMessage = "Error: couldn't load settings/themes.json.";
19
+    } else {
20
+      errorMessage = "No themes found in settings/themes.json.";
21
+    }
22
+    d3.select("#loading-bars").remove();
23
+    d3.select("#loading-message").html(errorMessage);
24
+    if (err) {
25
+      throw err;
26
+    }
27
+    return;
11 28
   }
12 29
 
13 30
   for (var key in themes) {