From 145d235094c61675abefdcfc6e74fafe54f17794 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Wed, 12 Oct 2022 12:50:08 +0200 Subject: 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. --- app/error-handler.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; -- cgit v1.2.1