Skip to content

Commit

Permalink
Fix fallback error handling
Browse files Browse the repository at this point in the history
Start using the correct API for window.addEventListener('error',..).
Unlike when using onerror, the handler function gets an event.
  • Loading branch information
samhed committed Nov 28, 2016
1 parent 38f3d92 commit 38d8cfd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ var UI;
"use strict";

// Fallback for all uncought errors
window.addEventListener('error', function(msg, url, line) {
window.addEventListener('error', function(e) {
try {
var file = e.filename;
var line = e.lineno;
var col = e.colno;
var msg = e.error.message;
document.getElementById('noVNC_fallback_error')
.classList.add("noVNC_open");
document.getElementById('noVNC_fallback_errormsg').innerHTML =
url + ' (' + line + ') <br><br>' + msg;
msg + '<br><br>' + 'at: ' + file + ':' + line + ':' + col;
} catch (exc) {
document.write("noVNC encountered an error.");
}
Expand Down

0 comments on commit 38d8cfd

Please sign in to comment.