summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2016-11-05 18:02:08 +0100
committerSamuel Mannehed <samuel@cendio.se>2016-11-10 14:33:23 +0100
commitd24de750b1a382c489445f6a56bcd632ed02b4f5 (patch)
tree08e7147fdc6838f3962eefea9d31b9b5a6d91861
parentb2cf3b68b35050567f02fc5e21a12c41023a361b (diff)
downloadnovnc-d24de750b1a382c489445f6a56bcd632ed02b4f5.tar.gz
Add fallback handling for uncought errors
-rw-r--r--app/styles/base.css37
-rw-r--r--app/ui.js15
-rw-r--r--vnc.html6
3 files changed, 58 insertions, 0 deletions
diff --git a/app/styles/base.css b/app/styles/base.css
index 03f6583..b90bcb2 100644
--- a/app/styles/base.css
+++ b/app/styles/base.css
@@ -173,6 +173,43 @@ input[type=button]:active, select:active {
}
/* ----------------------------------------
+ * Fallback error
+ * ----------------------------------------
+ */
+
+#noVNC_fallback_error {
+ position: fixed;
+ z-index: 3;
+ left: 50%;
+ transform: translate(-50%, -50px);
+ transition: 0.5s ease-in-out;
+
+ visibility: hidden;
+ opacity: 0;
+
+ top: 60px;
+ padding: 15px;
+ width: auto;
+
+ text-align: center;
+ font-weight: bold;
+ word-wrap: break-word;
+ color: #fff;
+
+ border-radius: 10px;
+ box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
+ background: rgba(200,55,55,0.8);
+}
+#noVNC_fallback_error.noVNC_open {
+ transform: translate(-50%, 0);
+ visibility: visible;
+ opacity: 1;
+}
+#noVNC_fallback_errormsg {
+ font-weight: normal;
+}
+
+/* ----------------------------------------
* Control Bar
* ----------------------------------------
*/
diff --git a/app/ui.js b/app/ui.js
index 1e55652..ceb7209 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -25,6 +25,21 @@ var UI;
(function () {
"use strict";
+ // Fallback for all uncought errors
+ window.addEventListener('error', function(msg, url, line) {
+ try {
+ document.getElementById('noVNC_fallback_error')
+ .classList.add("noVNC_open");
+ document.getElementById('noVNC_fallback_errormsg').innerHTML =
+ url + ' (' + line + ') <br><br>' + msg;
+ } catch (exc) {
+ document.write("noVNC encountered an error.");
+ }
+ // Don't return true since this would prevent the error
+ // from being printed to the browser console.
+ return false;
+ });
+
/* [begin skip-as-module] */
// Load supporting scripts
WebUtil.load_scripts(
diff --git a/vnc.html b/vnc.html
index 01828b4..ef880d2 100644
--- a/vnc.html
+++ b/vnc.html
@@ -65,6 +65,12 @@
</head>
<body>
+
+ <div id="noVNC_fallback_error">
+ <div>noVNC encountered an error:</div>
+ <div id="noVNC_fallback_errormsg"></div>
+ </div>
+
<!-- noVNC Control Bar -->
<div id="noVNC_control_bar_anchor" class="noVNC_vcenter">