@@ -43,6 +43,7 @@ import { CustomModesManager } from "../config/CustomModesManager"
4343import { CustomSupportPrompts , supportPrompt } from "../../shared/support-prompt"
4444
4545import { ACTION_NAMES } from "../CodeActionProvider"
46+ import { error } from "console"
4647
4748/*
4849https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/default/weather-webview/src/providers/WeatherViewProvider.ts
@@ -544,7 +545,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
544545 await this . postMessageToWebview ( { type : "listApiConfig" , listApiConfig } ) ,
545546 ] )
546547 } )
547- . catch ( console . error )
548+ . catch ( ( error ) =>
549+ this . outputChannel . appendLine (
550+ `Error list api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
551+ ) ,
552+ )
548553
549554 break
550555 case "newTask" :
@@ -664,7 +669,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
664669 await pWaitFor ( ( ) => this . cline === undefined || this . cline . didFinishAborting , {
665670 timeout : 3_000 ,
666671 } ) . catch ( ( ) => {
667- console . error ( "Failed to abort task" )
672+ this . outputChannel . appendLine (
673+ `Failed to abort task ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
674+ )
668675 } )
669676 if ( this . cline ) {
670677 // 'abandoned' will prevent this cline instance from affecting future cline instance gui. this may happen if its hanging on a streaming request
@@ -700,7 +707,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
700707 try {
701708 await this . mcpHub ?. restartConnection ( message . text ! )
702709 } catch ( error ) {
703- console . error ( `Failed to retry connection for ${ message . text } :` , error )
710+ this . outputChannel . appendLine (
711+ `Failed to retry connection for ${ message . text } : ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
712+ )
704713 }
705714 break
706715 }
@@ -712,15 +721,19 @@ export class ClineProvider implements vscode.WebviewViewProvider {
712721 message . alwaysAllow ! ,
713722 )
714723 } catch ( error ) {
715- console . error ( `Failed to toggle auto-approve for tool ${ message . toolName } :` , error )
724+ this . outputChannel . appendLine (
725+ `Failed to toggle auto-approve for tool ${ message . toolName } : ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
726+ )
716727 }
717728 break
718729 }
719730 case "toggleMcpServer" : {
720731 try {
721732 await this . mcpHub ?. toggleServerDisabled ( message . serverName ! , message . disabled ! )
722733 } catch ( error ) {
723- console . error ( `Failed to toggle MCP server ${ message . serverName } :` , error )
734+ this . outputChannel . appendLine (
735+ `Failed to toggle MCP server ${ message . serverName } : ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
736+ )
724737 }
725738 break
726739 }
@@ -800,7 +813,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
800813 await this . updateGlobalState ( "customSupportPrompts" , updatedPrompts )
801814 await this . postStateToWebview ( )
802815 } catch ( error ) {
803- console . error ( "Error update support prompt:" , error )
816+ this . outputChannel . appendLine (
817+ `Error update support prompt: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
818+ )
804819 vscode . window . showErrorMessage ( "Failed to update support prompt" )
805820 }
806821 break
@@ -822,7 +837,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
822837 await this . updateGlobalState ( "customSupportPrompts" , updatedPrompts )
823838 await this . postStateToWebview ( )
824839 } catch ( error ) {
825- console . error ( "Error reset support prompt:" , error )
840+ this . outputChannel . appendLine (
841+ `Error reset support prompt: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
842+ )
826843 vscode . window . showErrorMessage ( "Failed to reset support prompt" )
827844 }
828845 break
@@ -987,7 +1004,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
9871004 text : enhancedPrompt ,
9881005 } )
9891006 } catch ( error ) {
990- console . error ( "Error enhancing prompt:" , error )
1007+ this . outputChannel . appendLine (
1008+ `Error enhancing prompt: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1009+ )
9911010 vscode . window . showErrorMessage ( "Failed to enhance prompt" )
9921011 await this . postMessageToWebview ( {
9931012 type : "enhancedPrompt" ,
@@ -1042,7 +1061,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10421061 mode : message . mode ,
10431062 } )
10441063 } catch ( error ) {
1045- console . error ( "Error getting system prompt:" , error )
1064+ this . outputChannel . appendLine (
1065+ `Error getting system prompt: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1066+ )
10461067 vscode . window . showErrorMessage ( "Failed to get system prompt" )
10471068 }
10481069 break
@@ -1056,7 +1077,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10561077 commits,
10571078 } )
10581079 } catch ( error ) {
1059- console . error ( "Error searching commits:" , error )
1080+ this . outputChannel . appendLine (
1081+ `Error searching commits: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1082+ )
10601083 vscode . window . showErrorMessage ( "Failed to search commits" )
10611084 }
10621085 }
@@ -1076,7 +1099,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10761099
10771100 await this . postStateToWebview ( )
10781101 } catch ( error ) {
1079- console . error ( "Error create new api configuration:" , error )
1102+ this . outputChannel . appendLine (
1103+ `Error create new api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1104+ )
10801105 vscode . window . showErrorMessage ( "Failed to create api configuration" )
10811106 }
10821107 }
@@ -1099,7 +1124,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
10991124
11001125 await this . postStateToWebview ( )
11011126 } catch ( error ) {
1102- console . error ( "Error create new api configuration:" , error )
1127+ this . outputChannel . appendLine (
1128+ `Error create new api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1129+ )
11031130 vscode . window . showErrorMessage ( "Failed to create api configuration" )
11041131 }
11051132 }
@@ -1118,7 +1145,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
11181145
11191146 await this . postStateToWebview ( )
11201147 } catch ( error ) {
1121- console . error ( "Error load api configuration:" , error )
1148+ this . outputChannel . appendLine (
1149+ `Error load api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1150+ )
11221151 vscode . window . showErrorMessage ( "Failed to load api configuration" )
11231152 }
11241153 }
@@ -1154,7 +1183,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
11541183
11551184 await this . postStateToWebview ( )
11561185 } catch ( error ) {
1157- console . error ( "Error delete api configuration:" , error )
1186+ this . outputChannel . appendLine (
1187+ `Error delete api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1188+ )
11581189 vscode . window . showErrorMessage ( "Failed to delete api configuration" )
11591190 }
11601191 }
@@ -1165,7 +1196,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
11651196 await this . updateGlobalState ( "listApiConfigMeta" , listApiConfig )
11661197 this . postMessageToWebview ( { type : "listApiConfig" , listApiConfig } )
11671198 } catch ( error ) {
1168- console . error ( "Error get list api configuration:" , error )
1199+ this . outputChannel . appendLine (
1200+ `Error get list api configuration: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1201+ )
11691202 vscode . window . showErrorMessage ( "Failed to get list api configuration" )
11701203 }
11711204 break
@@ -1182,7 +1215,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
11821215 try {
11831216 await this . mcpHub ?. updateServerTimeout ( message . serverName , message . timeout )
11841217 } catch ( error ) {
1185- console . error ( `Failed to update timeout for ${ message . serverName } :` , error )
1218+ this . outputChannel . appendLine (
1219+ `Failed to update timeout for ${ message . serverName } : ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1220+ )
11861221 vscode . window . showErrorMessage ( `Failed to update server timeout` )
11871222 }
11881223 }
@@ -1423,7 +1458,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14231458 const models = await vscode . lm . selectChatModels ( { } )
14241459 return models || [ ]
14251460 } catch ( error ) {
1426- console . error ( "Error fetching VS Code LM models:" , error )
1461+ this . outputChannel . appendLine (
1462+ `Error fetching VS Code LM models: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1463+ )
14271464 return [ ]
14281465 }
14291466 }
@@ -1466,7 +1503,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14661503 throw new Error ( "Invalid response from OpenRouter API" )
14671504 }
14681505 } catch ( error ) {
1469- console . error ( "Error exchanging code for API key:" , error )
1506+ this . outputChannel . appendLine (
1507+ `Error exchanging code for API key: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1508+ )
14701509 throw error
14711510 }
14721511
@@ -1496,7 +1535,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
14961535 throw new Error ( "Invalid response from Glama API" )
14971536 }
14981537 } catch ( error ) {
1499- console . error ( "Error exchanging code for API key:" , error )
1538+ this . outputChannel . appendLine (
1539+ `Error exchanging code for API key: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1540+ )
15001541 throw error
15011542 }
15021543
@@ -1583,12 +1624,14 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15831624 models [ rawModel . id ] = modelInfo
15841625 }
15851626 } else {
1586- console . error ( "Invalid response from Glama API" )
1627+ this . outputChannel . appendLine ( "Invalid response from Glama API" )
15871628 }
15881629 await fs . writeFile ( glamaModelsFilePath , JSON . stringify ( models ) )
1589- console . log ( " Glama models fetched and saved" , models )
1630+ this . outputChannel . appendLine ( ` Glama models fetched and saved: ${ JSON . stringify ( models , null , 2 ) } ` )
15901631 } catch ( error ) {
1591- console . error ( "Error fetching Glama models:" , error )
1632+ this . outputChannel . appendLine (
1633+ `Error fetching Glama models: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1634+ )
15921635 }
15931636
15941637 await this . postMessageToWebview ( { type : "glamaModels" , glamaModels : models } )
@@ -1706,12 +1749,14 @@ export class ClineProvider implements vscode.WebviewViewProvider {
17061749 models [ rawModel . id ] = modelInfo
17071750 }
17081751 } else {
1709- console . error ( "Invalid response from OpenRouter API" )
1752+ this . outputChannel . appendLine ( "Invalid response from OpenRouter API" )
17101753 }
17111754 await fs . writeFile ( openRouterModelsFilePath , JSON . stringify ( models ) )
1712- console . log ( " OpenRouter models fetched and saved" , models )
1755+ this . outputChannel . appendLine ( ` OpenRouter models fetched and saved: ${ JSON . stringify ( models , null , 2 ) } ` )
17131756 } catch ( error ) {
1714- console . error ( "Error fetching OpenRouter models:" , error )
1757+ this . outputChannel . appendLine (
1758+ `Error fetching OpenRouter models: ${ JSON . stringify ( error , Object . getOwnPropertyNames ( error ) , 2 ) } ` ,
1759+ )
17151760 }
17161761
17171762 await this . postMessageToWebview ( { type : "openRouterModels" , openRouterModels : models } )
0 commit comments