diff options
author | Samuel Mannehed <samuel@cendio.se> | 2022-10-12 12:50:08 +0200 |
---|---|---|
committer | Samuel Mannehed <samuel@cendio.se> | 2022-10-12 13:01:23 +0200 |
commit | 145d235094c61675abefdcfc6e74fafe54f17794 (patch) | |
tree | 20c6f16fa2549ad6d1c2b8d807a391c6eeba5792 | |
parent | 4ecb44111d16048ef1ee3a7e96acb66ac9c39303 (diff) | |
download | novnc-145d235094c61675abefdcfc6e74fafe54f17794.tar.gz |
Make error handler's focus changes best-effort
When the error handler itself causes an exception, it falls back to a
simple document.write(). This means the proper error dialog isn't shown
when this happens.
The focus changes that were added to the error handler in e1f8232b are
not crucial for its function. If these focus changes causes an exception
we can just ignore that.
-rw-r--r-- | app/error-handler.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/error-handler.js b/app/error-handler.js index 675bc51..67b6372 100644 --- a/app/error-handler.js +++ b/app/error-handler.js @@ -51,6 +51,12 @@ function handleError(event, err) { document.getElementById('noVNC_fallback_error') .classList.add("noVNC_open"); + } catch (exc) { + document.write("noVNC encountered an error."); + } + + // Try to disable keyboard interaction, best effort + try { // Remove focus from the currently focused element in order to // prevent keyboard interaction from continuing if (document.activeElement) { document.activeElement.blur(); } @@ -61,8 +67,9 @@ function handleError(event, err) { elem.setAttribute("tabindex", "-1"); }); } catch (exc) { - document.write("noVNC encountered an error."); + // Do nothing } + // Don't return true since this would prevent the error // from being printed to the browser console. return false; |