11<template >
22 <div class =" containers" >
3+ <banner
4+ v-if =" error"
5+ color =" error"
6+ @close =" error = null"
7+ >
8+ {{ error }}
9+ </banner >
310 <SortableTable
411 ref =" sortableTableRef"
512 class =" containersTable"
98105</template >
99106
100107<script >
101- import { BadgeState } from ' @rancher/components' ;
102- import { shell } from ' electron' ;
108+ import {BadgeState , Banner } from ' @rancher/components' ;
109+ import {shell } from ' electron' ;
103110import Vue from ' vue' ;
104- import { mapGetters } from ' vuex' ;
111+ import {mapGetters } from ' vuex' ;
105112
106113import SortableTable from ' @pkg/components/SortableTable' ;
107- import { ContainerEngine } from ' @pkg/config/settings' ;
108- import { ipcRenderer } from ' @pkg/utils/ipcRenderer' ;
114+ import {ContainerEngine } from ' @pkg/config/settings' ;
115+ import {ipcRenderer } from ' @pkg/utils/ipcRenderer' ;
109116
110117let containerCheckInterval = null ;
111118
@@ -117,7 +124,7 @@ let containerCheckInterval = null;
117124export default Vue .extend ({
118125 name: ' Containers' ,
119126 title: ' Containers' ,
120- components: { SortableTable, BadgeState },
127+ components: {SortableTable, BadgeState, Banner },
121128 data () {
122129 return {
123130 /** @type import('@pkg/config/settings').Settings | undefined */
@@ -126,6 +133,7 @@ export default Vue.extend({
126133 containersList: null ,
127134 showRunning: false ,
128135 containersNamespaces: [],
136+ error: null ,
129137 headers: [
130138 // INFO: Disable for now since we can only get the running containers.
131139 {
@@ -418,8 +426,34 @@ export default Vue.extend({
418426
419427 return stdout;
420428 } catch (error) {
421- window .alert (error .message );
422- console .error (` Error executing command ${ command } ` , error .message );
429+ const extractErrorMessage = (err ) => {
430+ const rawMessage = err? .message || err? .stderr || err || ' ' ;
431+
432+ if (typeof rawMessage === ' string' ) {
433+ // Extract message from fatal/error format: time="..." level=fatal msg="actual message"
434+ const msgMatch = rawMessage .match (/ msg="((?:[^ "\\ ] | \\ . )* )"/ );
435+ if (msgMatch) {
436+ return msgMatch[1 ];
437+ }
438+
439+ // Fallback: remove timestamp and level prefixes
440+ const cleanedMessage = rawMessage
441+ .replace (/ time="[^ "] * "\s * / g , ' ' )
442+ .replace (/ level=(fatal| error| info)\s * / g , ' ' )
443+ .replace (/ msg="/ g , ' ' )
444+ .replace (/ "\s * Error: exit status \d + / g , ' ' )
445+ .trim ();
446+
447+ if (cleanedMessage) {
448+ return cleanedMessage;
449+ }
450+ }
451+
452+ return ` Failed to execute command: ${ command} ` ;
453+ };
454+
455+ this .error = extractErrorMessage (error);
456+ console .error (` Error executing command ${ command} ` , error);
423457 }
424458 },
425459 shortSha (sha ) {
0 commit comments