Add fallback handling for uncought errors

This commit is contained in:
Samuel Mannehed 2016-11-05 18:02:08 +01:00
parent b2cf3b68b3
commit d24de750b1
3 changed files with 58 additions and 0 deletions

View File

@ -172,6 +172,43 @@ input[type=button]:active, select:active {
pointer-events: auto; pointer-events: auto;
} }
/* ----------------------------------------
* 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 * Control Bar
* ---------------------------------------- * ----------------------------------------

View File

@ -25,6 +25,21 @@ var UI;
(function () { (function () {
"use strict"; "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] */ /* [begin skip-as-module] */
// Load supporting scripts // Load supporting scripts
WebUtil.load_scripts( WebUtil.load_scripts(

View File

@ -65,6 +65,12 @@
</head> </head>
<body> <body>
<div id="noVNC_fallback_error">
<div>noVNC encountered an error:</div>
<div id="noVNC_fallback_errormsg"></div>
</div>
<!-- noVNC Control Bar --> <!-- noVNC Control Bar -->
<div id="noVNC_control_bar_anchor" class="noVNC_vcenter"> <div id="noVNC_control_bar_anchor" class="noVNC_vcenter">