FIX: better error handling

FIX: better error handling

diff --git a/javascripts/discourse/initializers/initialize-for-hljs-theme-picker.js.es6 b/javascripts/discourse/initializers/initialize-for-hljs-theme-picker.js.es6
index d83acbf..6866084 100644
--- a/javascripts/discourse/initializers/initialize-for-hljs-theme-picker.js.es6
+++ b/javascripts/discourse/initializers/initialize-for-hljs-theme-picker.js.es6
@@ -4,14 +4,20 @@ export default {
   name: "hljs-theme-picker",
   initialize() {
     withPluginApi("0.8.7", api => {
-      const theme = settings.hljs_theme;
-      const path = settings.theme_uploads[theme];
-      // TODO: use loadCSS here instead. loadCSS currently causes CORS issues.
-      const link = document.createElement("link");
-      link.setAttribute("rel", "stylesheet");
-      link.setAttribute("type", "text/css");
-      link.setAttribute("href", path);
-      document.head.appendChild(link);
+      try {
+        const theme = settings.hljs_theme;
+        const path = settings.theme_uploads[theme];
+        const link = document.createElement("link");
+        link.setAttribute("rel", "stylesheet");
+        link.setAttribute("type", "text/css");
+        link.setAttribute("href", path);
+        document.head.appendChild(link);
+      } catch (error) {
+        console.error(error);
+        console.error(
+          "There is a problem with codeblock theme picker, Please check if you've added CSS to the theme_authorized_extensions site setting"
+        );
+      }
     });
   }
 };

GitHub sha: ae0a29cfb47c1deed4521f76bfee08fe69868f7b