Unify error handling and display logic (#4984)
* Unify error handling and display Several improvements to error handling and reporting within the Cline extension, focusing on providing more informative error messages to the user and improving telemetry data. - **Error Handling:** - Introduces a `ClineError` class to encapsulate Cline-specific errors, providing structured data about the error (status code, request ID, etc.). - The `ErrorService` now creates and logs `ClineError` instances, improving error reporting to Sentry and telemetry. - Removes redundant error formatting logic from `src/core/task/utils.ts`, relying on the `ClineError` class for consistent error representation. - The Cline API handler now throws the raw error, allowing the `ClineError` class to handle the error formatting. - **UI Improvements:** - Introduces new UI components (`ErrorRow`, `ErrorBlockTitle`) to display error messages in a more user-friendly format within the chat interface. - Displays credit limit errors with detailed information and a link to purchase credits. - Improves the display of rate limit errors and authentication errors. - Adds specific handling for PowerShell-related errors, providing a link to a troubleshooting guide. - **Telemetry:** - Captures provider API errors using `ClineError` data, providing more detailed information about the error in telemetry reports. - **Other Changes:** - Fixes an import path in `src/services/posthog/PostHogClientProvider.ts`. - Adds tests for the new UI components. - Adds `error` field to `ClineMessage` to transport `ClineError` instances to the webview. These changes aim to provide a better user experience by displaying more informative error messages and improving the overall reliability of the Cline extension. * include provider id * includes model and provider id * fix test * return gracefully for empty response
This commit is contained in:
12 files changed
+726
-407
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import * as Sentry from "@sentry/browser"
|
||||
import * as vscode from "vscode"
|
||||
import { telemetryService } from "@/services/posthog/telemetry/TelemetryService"
|
||||
import { telemetryService } from "../posthog/telemetry/TelemetryService"
|
||||
import * as pkg from "../../../package.json"
|
||||
import { ClineError } from "./ClineError"
|
||||
|
||||
let telemetryLevel = vscode.workspace.getConfiguration("telemetry").get<string>("telemetryLevel", "all")
|
||||
let isTelemetryEnabled = ["all", "error"].includes(telemetryLevel)
|
||||
@@ -15,6 +16,8 @@ vscode.workspace.onDidChangeConfiguration(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const isDev = process.env.IS_DEV === "true"
|
||||
|
||||
export class ErrorService {
|
||||
private static serviceEnabled: boolean
|
||||
private static serviceLevel: string
|
||||
@@ -29,7 +32,7 @@ export class ErrorService {
|
||||
beforeSend(event) {
|
||||
// TelemetryService keeps track of whether the user has opted in to telemetry/error reporting
|
||||
const isUserManuallyOptedIn = telemetryService.isTelemetryEnabled()
|
||||
if (isUserManuallyOptedIn && ErrorService.isEnabled()) {
|
||||
if (isUserManuallyOptedIn && ErrorService.isEnabled() && !isDev) {
|
||||
return event
|
||||
}
|
||||
return null
|
||||
@@ -65,7 +68,7 @@ export class ErrorService {
|
||||
}
|
||||
}
|
||||
|
||||
static logException(error: Error): void {
|
||||
static logException(error: Error | ClineError): void {
|
||||
// Don't log if telemetry is off
|
||||
const isUserManuallyOptedIn = telemetryService.isTelemetryEnabled()
|
||||
if (!isUserManuallyOptedIn || !ErrorService.isEnabled()) {
|
||||
@@ -93,4 +96,8 @@ export class ErrorService {
|
||||
static isEnabled(): boolean {
|
||||
return ErrorService.serviceEnabled
|
||||
}
|
||||
|
||||
static toClineError(rawError: any, modelId?: string, providerId?: string): ClineError {
|
||||
return ClineError.transform(rawError, modelId, providerId)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user