import { classifyClineError } from "./errors.js"; import { PROVIDER_NAME } from "./env.js"; /** Kept as a deprecated alias. */ export const handleClineFreeError = handleClineError; export function handleClineError( event: { message: unknown }, ctx: { hasUI: boolean; ui: { notify: (msg: string, type: "info" | "warning" | "error") => void }; model?: { provider?: string }; }, ): void { if (!event.message) return; const msg = event.message as { stopReason?: string; errorMessage?: string; provider?: string; }; if (msg.stopReason !== "error" || !msg.errorMessage) return; const provider = msg.provider ?? ctx.model?.provider; if (provider !== PROVIDER_NAME) return; const { message: friendlyMessage } = classifyClineError(msg.errorMessage); if (ctx.hasUI) { ctx.ui.notify(friendlyMessage, "error"); } else { console.error(`[cline] ${friendlyMessage}`); } }