]>
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.
8 // Fallback for all uncought errors
9 function handleError (event
, err
) {
11 const msg
= document
.getElementById('noVNC_fallback_errormsg');
13 // Only show the initial error
14 if (msg
.hasChildNodes()) {
18 let div
= document
.createElement("div");
19 div
.classList
.add('noVNC_message');
20 div
.appendChild(document
.createTextNode(event
.message
));
24 div
= document
.createElement("div");
25 div
.className
= 'noVNC_location';
26 let text
= event
.filename
;
27 if (event
.lineno
!== undefined) {
28 text
+= ":" + event
.lineno
;
29 if (event
.colno
!== undefined) {
30 text
+= ":" + event
.colno
;
33 div
.appendChild(document
.createTextNode(text
));
37 if (err
&& err
.stack
) {
38 div
= document
.createElement("div");
39 div
.className
= 'noVNC_stack';
40 div
.appendChild(document
.createTextNode(err
.stack
));
44 document
.getElementById('noVNC_fallback_error')
45 .classList
.add("noVNC_open");
47 document
.write("noVNC encountered an error.");
49 // Don't return true since this would prevent the error
50 // from being printed to the browser console.
53 window
.addEventListener('error', function (evt
) { handleError(evt
, evt
.error
); });
54 window
.addEventListener('unhandledrejection', function (evt
) { handleError(evt
.reason
, evt
.reason
); });