@@ -22,10 +22,21 @@ export class McpServerFeature {
22
22
constructor (
23
23
private context : vscode . ExtensionContext ,
24
24
private reporter : TelemetryReporter ,
25
+ private outputChannel : vscode . OutputChannel ,
25
26
) {
26
27
this . activate ( ) ;
27
28
}
28
29
30
+ /**
31
+ * Helper method to format and log error information
32
+ */
33
+ private logError ( message : string , error : unknown ) : void {
34
+ this . outputChannel . appendLine ( `${ message } : ${ String ( error ) } ` ) ;
35
+ if ( error instanceof Error && error . stack ) {
36
+ this . outputChannel . appendLine ( `Stack trace: ${ error . stack } ` ) ;
37
+ }
38
+ }
39
+
29
40
public activate ( ) : void {
30
41
try {
31
42
if ( ! this . isMcpApiAvailable ( ) ) {
@@ -37,7 +48,7 @@ export class McpServerFeature {
37
48
this . context . subscriptions . push ( provider ) ;
38
49
}
39
50
} catch ( error ) {
40
- console . error ( 'Failed to register MCP server definition provider: ' , error ) ;
51
+ this . logError ( 'Failed to register MCP server definition provider' , error ) ;
41
52
// Don't throw - let the extension continue to work without MCP server
42
53
}
43
54
}
@@ -59,7 +70,7 @@ export class McpServerFeature {
59
70
} ,
60
71
} ) ;
61
72
} catch ( error ) {
62
- console . error ( 'Error registering MCP server provider: ' , error ) ;
73
+ this . logError ( 'Error registering MCP server provider' , error ) ;
63
74
return undefined ;
64
75
}
65
76
}
@@ -82,7 +93,7 @@ export class McpServerFeature {
82
93
83
94
return [ server ] ;
84
95
} catch ( error ) {
85
- console . error ( 'Error providing MCP server definitions: ' , error ) ;
96
+ this . logError ( 'Error providing MCP server definitions' , error ) ;
86
97
return [ ] ;
87
98
}
88
99
}
@@ -98,7 +109,7 @@ export class McpServerFeature {
98
109
99
110
return true ;
100
111
} catch ( error ) {
101
- console . log ( error ) ;
112
+ this . logError ( 'Docker validation error' , error ) ;
102
113
return false ;
103
114
}
104
115
}
@@ -127,7 +138,7 @@ export class McpServerFeature {
127
138
await execAsync ( 'docker info' , { timeout : 5000 } ) ;
128
139
return true ;
129
140
} catch ( error ) {
130
- console . log ( 'Docker daemon check failed: ' , error ) ;
141
+ this . logError ( 'Docker daemon check failed' , error ) ;
131
142
void vscode . window
132
143
. showWarningMessage (
133
144
'Docker is installed but not running. Please start Docker to use the Terraform MCP Server.' ,
0 commit comments