mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Merge pull request #599 from samhvw8/refactor/change-console-log-to-output-channel
refactor: improve error logging in ClineProvider
This commit is contained in:
@@ -579,7 +579,11 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
await this.postMessageToWebview({ type: "listApiConfig", listApiConfig }),
|
await this.postMessageToWebview({ type: "listApiConfig", listApiConfig }),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
.catch((error) =>
|
||||||
|
this.outputChannel.appendLine(
|
||||||
|
`Error list api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
break
|
break
|
||||||
case "newTask":
|
case "newTask":
|
||||||
@@ -702,8 +706,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
this.cline.abortTask()
|
this.cline.abortTask()
|
||||||
await pWaitFor(() => this.cline === undefined || this.cline.didFinishAborting, {
|
await pWaitFor(() => this.cline === undefined || this.cline.didFinishAborting, {
|
||||||
timeout: 3_000,
|
timeout: 3_000,
|
||||||
}).catch(() => {
|
}).catch((error) => {
|
||||||
console.error("Failed to abort task")
|
this.outputChannel.appendLine(
|
||||||
|
`Failed to abort task ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
if (this.cline) {
|
if (this.cline) {
|
||||||
// 'abandoned' will prevent this cline instance from affecting future cline instance gui. this may happen if its hanging on a streaming request
|
// 'abandoned' will prevent this cline instance from affecting future cline instance gui. this may happen if its hanging on a streaming request
|
||||||
@@ -739,7 +745,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
try {
|
try {
|
||||||
await this.mcpHub?.restartConnection(message.text!)
|
await this.mcpHub?.restartConnection(message.text!)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to retry connection for ${message.text}:`, error)
|
this.outputChannel.appendLine(
|
||||||
|
`Failed to retry connection for ${message.text}: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -751,7 +759,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
message.alwaysAllow!,
|
message.alwaysAllow!,
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to toggle auto-approve for tool ${message.toolName}:`, error)
|
this.outputChannel.appendLine(
|
||||||
|
`Failed to toggle auto-approve for tool ${message.toolName}: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -759,7 +769,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
try {
|
try {
|
||||||
await this.mcpHub?.toggleServerDisabled(message.serverName!, message.disabled!)
|
await this.mcpHub?.toggleServerDisabled(message.serverName!, message.disabled!)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to toggle MCP server ${message.serverName}:`, error)
|
this.outputChannel.appendLine(
|
||||||
|
`Failed to toggle MCP server ${message.serverName}: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -839,7 +851,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
await this.updateGlobalState("customSupportPrompts", updatedPrompts)
|
await this.updateGlobalState("customSupportPrompts", updatedPrompts)
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error update support prompt:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error update support prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to update support prompt")
|
vscode.window.showErrorMessage("Failed to update support prompt")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -861,7 +875,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
await this.updateGlobalState("customSupportPrompts", updatedPrompts)
|
await this.updateGlobalState("customSupportPrompts", updatedPrompts)
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error reset support prompt:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error reset support prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to reset support prompt")
|
vscode.window.showErrorMessage("Failed to reset support prompt")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -1026,7 +1042,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
text: enhancedPrompt,
|
text: enhancedPrompt,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error enhancing prompt:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error enhancing prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to enhance prompt")
|
vscode.window.showErrorMessage("Failed to enhance prompt")
|
||||||
await this.postMessageToWebview({
|
await this.postMessageToWebview({
|
||||||
type: "enhancedPrompt",
|
type: "enhancedPrompt",
|
||||||
@@ -1082,7 +1100,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
mode: message.mode,
|
mode: message.mode,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error getting system prompt:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error getting system prompt: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to get system prompt")
|
vscode.window.showErrorMessage("Failed to get system prompt")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -1096,7 +1116,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
commits,
|
commits,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error searching commits:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error searching commits: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to search commits")
|
vscode.window.showErrorMessage("Failed to search commits")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1116,7 +1138,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
|
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error create new api configuration:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error create new api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to create api configuration")
|
vscode.window.showErrorMessage("Failed to create api configuration")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1139,7 +1163,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
|
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error create new api configuration:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error create new api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to create api configuration")
|
vscode.window.showErrorMessage("Failed to create api configuration")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1184,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
|
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error load api configuration:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error load api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to load api configuration")
|
vscode.window.showErrorMessage("Failed to load api configuration")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1194,7 +1222,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
|
|
||||||
await this.postStateToWebview()
|
await this.postStateToWebview()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error delete api configuration:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error delete api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to delete api configuration")
|
vscode.window.showErrorMessage("Failed to delete api configuration")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1205,7 +1235,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
await this.updateGlobalState("listApiConfigMeta", listApiConfig)
|
||||||
this.postMessageToWebview({ type: "listApiConfig", listApiConfig })
|
this.postMessageToWebview({ type: "listApiConfig", listApiConfig })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error get list api configuration:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error get list api configuration: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage("Failed to get list api configuration")
|
vscode.window.showErrorMessage("Failed to get list api configuration")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -1236,7 +1268,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
try {
|
try {
|
||||||
await this.mcpHub?.updateServerTimeout(message.serverName, message.timeout)
|
await this.mcpHub?.updateServerTimeout(message.serverName, message.timeout)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to update timeout for ${message.serverName}:`, error)
|
this.outputChannel.appendLine(
|
||||||
|
`Failed to update timeout for ${message.serverName}: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
vscode.window.showErrorMessage(`Failed to update server timeout`)
|
vscode.window.showErrorMessage(`Failed to update server timeout`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1477,7 +1511,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
const models = await vscode.lm.selectChatModels({})
|
const models = await vscode.lm.selectChatModels({})
|
||||||
return models || []
|
return models || []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching VS Code LM models:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error fetching VS Code LM models: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1520,7 +1556,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
throw new Error("Invalid response from OpenRouter API")
|
throw new Error("Invalid response from OpenRouter API")
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error exchanging code for API key:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error exchanging code for API key: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1550,7 +1588,9 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
throw new Error("Invalid response from Glama API")
|
throw new Error("Invalid response from Glama API")
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error exchanging code for API key:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error exchanging code for API key: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1637,12 +1677,14 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
models[rawModel.id] = modelInfo
|
models[rawModel.id] = modelInfo
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("Invalid response from Glama API")
|
this.outputChannel.appendLine("Invalid response from Glama API")
|
||||||
}
|
}
|
||||||
await fs.writeFile(glamaModelsFilePath, JSON.stringify(models))
|
await fs.writeFile(glamaModelsFilePath, JSON.stringify(models))
|
||||||
console.log("Glama models fetched and saved", models)
|
this.outputChannel.appendLine(`Glama models fetched and saved: ${JSON.stringify(models, null, 2)}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching Glama models:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error fetching Glama models: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.postMessageToWebview({ type: "glamaModels", glamaModels: models })
|
await this.postMessageToWebview({ type: "glamaModels", glamaModels: models })
|
||||||
@@ -1760,12 +1802,14 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||||||
models[rawModel.id] = modelInfo
|
models[rawModel.id] = modelInfo
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("Invalid response from OpenRouter API")
|
this.outputChannel.appendLine("Invalid response from OpenRouter API")
|
||||||
}
|
}
|
||||||
await fs.writeFile(openRouterModelsFilePath, JSON.stringify(models))
|
await fs.writeFile(openRouterModelsFilePath, JSON.stringify(models))
|
||||||
console.log("OpenRouter models fetched and saved", models)
|
this.outputChannel.appendLine(`OpenRouter models fetched and saved: ${JSON.stringify(models, null, 2)}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching OpenRouter models:", error)
|
this.outputChannel.appendLine(
|
||||||
|
`Error fetching OpenRouter models: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.postMessageToWebview({ type: "openRouterModels", openRouterModels: models })
|
await this.postMessageToWebview({ type: "openRouterModels", openRouterModels: models })
|
||||||
|
|||||||
Reference in New Issue
Block a user