Add fallback handling for uncought errors
This commit is contained in:
parent
b2cf3b68b3
commit
d24de750b1
|
@ -172,6 +172,43 @@ input[type=button]:active, select:active {
|
|||
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
|
||||
* ----------------------------------------
|
||||
|
|
15
app/ui.js
15
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(
|
||||
|
|
Loading…
Reference in New Issue