Skip to content

Commit

Permalink
Merge pull request novnc#713 from kanaka/properdisconnections
Browse files Browse the repository at this point in the history
Better error handling
  • Loading branch information
samhed authored Nov 14, 2016
2 parents 80b7dde + 67cd207 commit e1f853e
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 74 deletions.
37 changes: 37 additions & 0 deletions app/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
* ----------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading

0 comments on commit e1f853e

Please sign in to comment.