@@ -2575,9 +2575,20 @@ class Dashboard {
25752575
25762576 until(promise)
25772577 .spin(s => exec.setLabel(`${s} ${namespace}/${name}/${container}`))
2578+ .catch(error => {
2579+ exec.setLabel(`${namespace}/${name}/${container}`);
2580+ exec.terminal.write(`\x1b[31m${error}\x1b[m\r\n`);
2581+ exec.terminal.write('Type Ctrl-C to close\r\n');
2582+ exec.terminal.once('key C-c', () => {
2583+ exec.terminal.dispose();
2584+ navbar.remove(byId);
2585+ });
2586+ return Promise.reject();
2587+ })
25782588 .then(() => debug.log(`{grey-fg}Remote shell into '${namespace}/${name}/${container}'{/grey-fg}`))
25792589 .then(() => exec.setLabel(`${namespace}/${name}/${container}`))
25802590 .then(() => {
2591+ // TODO: add retry on timeout
25812592 const { promise, cancellation } = get(client.watch_pod(namespace, name, pod.metadata.resourceVersion), { generator: function* () {
25822593 let change;
25832594 while (change = yield) {
@@ -2600,8 +2611,9 @@ class Dashboard {
26002611 cancellations.add(watch, cancellation);
26012612 return promise;
26022613 })
2603- // TODO: display error details in terminal
2604- .catch(error => console.error(error.stack));
2614+ .catch(error => {
2615+ if (error) console.error(error.stack);
2616+ });
26052617 });
26062618
26072619 pods_table.on('select', (item, i) => {
@@ -2705,12 +2717,19 @@ class Dashboard {
27052717 until(logs.promise)
27062718 .spin(s => pod_log.setLabel(`${s} Logs {grey-fg}[${container.name}]{/grey-fg}`))
27072719 .cancel(c => cancellations.add('dashboard.pod.logs', c))
2720+ .catch(error => {
2721+ pod_log.setLabel(`Logs {grey-fg}[${container.name}]{/grey-fg}`);
2722+ pod_log.log(`\x1b[31mError: ${error.message}\x1b[m`);
2723+ return Promise.reject();
2724+ })
27082725 .then(() => debug.log(`{grey-fg}Following log for ${name}/${container.name} ...{/grey-fg}`))
27092726 .then(() => k8s.isPodTerminating(getPodByUid(pod.metadata.uid))
27102727 ? pod_log.setLabel(`Logs {grey-fg}[${container.name}]{/grey-fg} {red-fg}TERMINATING{/red-fg}`)
27112728 : pod_log.setLabel(`Logs {grey-fg}[${container.name}]{/grey-fg}`))
27122729 .then(() => screen.render())
2713- .catch(error => console.error(error.stack));
2730+ .catch(error => {
2731+ if (error) console.error(error.stack);
2732+ });
27142733
27152734 const stats = updateStatsFromCAdvisor(pod, container);
27162735 cancellations.add('dashboard.pod.stats', stats.cancellation);
@@ -3050,6 +3069,7 @@ class Exec extends Duplex {
30503069 }
30513070 },
30523071 });
3072+ this.terminal = terminal;
30533073
30543074 const browserCopyToClipboard = function (event) {
30553075 if (terminal.hasSelection()) {
0 commit comments