[pbs-devel] [PATCH xtermjs v3 3/4] ui: improve error message handling
Dominik Csapak
d.csapak at proxmox.com
Tue Jul 21 11:00:47 CEST 2020
by splitting the msg and code, and only showing the existing parts
also actually read the msg/code from the event by giving it from
tryReconnect to stopTerminal
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/www/main.js | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/www/main.js b/src/www/main.js
index 4da40b0..bb71812 100644
--- a/src/www/main.js
+++ b/src/www/main.js
@@ -26,7 +26,7 @@ var nodename = getQueryParameter('node');
var cmd = getQueryParameter('cmd');
var cmdOpts = getQueryParameter('cmd-opts');
-function updateState(newState, msg) {
+function updateState(newState, msg, code) {
var timeout, severity, message;
switch (newState) {
case states.connecting:
@@ -77,8 +77,15 @@ function updateState(newState, msg) {
default:
throw "unknown state";
}
+ let msgArr = [];
if (msg) {
- message += " (" + msg + ")";
+ msgArr.push(msg);
+ }
+ if (code !== undefined) {
+ msgArr.push(`Code: ${code}`);
+ }
+ if (msgArr.length > 0) {
+ message += ` (${msgArr.join(', ')})`;
}
state = newState;
showMsg(message, timeout, severity);
@@ -279,11 +286,11 @@ function checkMigration() {
});
}
-function tryReconnect() {
+function tryReconnect(event) {
var time_since_started = new Date() - starttime;
var type = getQueryParameter('console');
if (time_since_started < 5*1000 || type === 'shell' || type === 'cmd') { // 5 seconds
- stopTerminal();
+ stopTerminal(event);
return;
}
@@ -301,7 +308,7 @@ function stopTerminal(event) {
clearEvents();
clearInterval(ping);
socket.close();
- updateState(states.disconnected, event.msg + event.code);
+ updateState(states.disconnected, event.reason, event.code);
}
function errorTerminal(event) {
@@ -310,5 +317,5 @@ function errorTerminal(event) {
clearInterval(ping);
socket.close();
term.dispose();
- updateState(states.disconnected, event.msg + event.code);
+ updateState(states.disconnected, event.msg, event.code);
}
--
2.20.1
More information about the pbs-devel
mailing list