]>
git.proxmox.com Git - mirror_novnc.git/blob - app/error-handler.js
1 // NB: this should *not* be included as a module until we have
2 // native support in the browsers, so that our error handler
3 // can catch script-loading errors.
9 // Fallback for all uncought errors
10 function handleError (event
, err
) {
12 const msg
= document
.getElementById('noVNC_fallback_errormsg');
14 // Only show the initial error
15 if (msg
.hasChildNodes()) {
19 var div
= document
.createElement("div");
20 div
.classList
.add('noVNC_message');
21 div
.appendChild(document
.createTextNode(event
.message
));
25 div
= document
.createElement("div");
26 div
.className
= 'noVNC_location';
27 var text
= event
.filename
;
28 if (event
.lineno
!== undefined) {
29 text
+= ":" + event
.lineno
;
30 if (event
.colno
!== undefined) {
31 text
+= ":" + event
.colno
;
34 div
.appendChild(document
.createTextNode(text
));
38 if (err
&& (err
.stack
!== undefined)) {
39 div
= document
.createElement("div");
40 div
.className
= 'noVNC_stack';
41 div
.appendChild(document
.createTextNode(err
.stack
));
45 document
.getElementById('noVNC_fallback_error')
46 .classList
.add("noVNC_open");
48 document
.write("noVNC encountered an error.");
50 // Don't return true since this would prevent the error
51 // from being printed to the browser console.
54 window
.addEventListener('error', function (evt
) { handleError(evt
, evt
.error
); });
55 window
.addEventListener('unhandledrejection', function (evt
) { handleError(evt
.reason
, evt
.reason
); });