88import type { SentryContext } from "../../context.js" ;
99import { triggerSolutionPlanning } from "../../lib/api-client.js" ;
1010import { buildCommand , numberParser } from "../../lib/command.js" ;
11- import { ApiError , ValidationError } from "../../lib/errors.js" ;
11+ import { ValidationError } from "../../lib/errors.js" ;
1212import { CommandOutput } from "../../lib/formatters/output.js" ;
13- import {
14- formatSolution ,
15- handleSeerApiError ,
16- } from "../../lib/formatters/seer.js" ;
13+ import { formatSolution } from "../../lib/formatters/seer.js" ;
1714import {
1815 applyFreshFlag ,
1916 FRESH_ALIASES ,
2017 FRESH_FLAG ,
2118} from "../../lib/list-command.js" ;
2219import { logger } from "../../lib/logger.js" ;
23- import { classifySeerError , recordSeerOutcome } from "../../lib/telemetry.js" ;
20+ import { recordSeerOutcome } from "../../lib/telemetry.js" ;
2421import {
2522 type AutofixState ,
2623 extractRootCauses ,
@@ -30,6 +27,7 @@ import {
3027} from "../../types/seer.js" ;
3128import {
3229 ensureRootCauseAnalysis ,
30+ handleSeerCommandError ,
3331 issueIdPositional ,
3432 pollAutofixState ,
3533 resolveOrgAndIssueId ,
@@ -126,40 +124,6 @@ function buildPlanData(state: AutofixState): PlanData {
126124 } ;
127125}
128126
129- /**
130- * Handle errors in Seer commands with outcome recording.
131- *
132- * Records the Seer outcome if not already recorded, maps API errors to
133- * Seer-specific errors, and re-throws. Extracted from the catch block to
134- * keep command function complexity under the Biome limit.
135- *
136- * @param error - The caught error
137- * @param recorded - Whether outcome was already recorded before the error
138- * @param resolvedOrg - Org slug for Seer error messages
139- * @returns never — always throws
140- */
141- function handleSeerCommandError (
142- error : unknown ,
143- recorded : boolean ,
144- resolvedOrg : string | undefined
145- ) : never {
146- if ( ! recorded ) {
147- if ( error instanceof ApiError ) {
148- const mapped = handleSeerApiError (
149- error . status ,
150- error . detail ,
151- resolvedOrg
152- ) ;
153- recordSeerOutcome ( classifySeerError ( mapped ) ) ;
154- throw mapped ;
155- }
156- recordSeerOutcome ( classifySeerError ( error ) ) ;
157- } else if ( error instanceof ApiError ) {
158- throw handleSeerApiError ( error . status , error . detail , resolvedOrg ) ;
159- }
160- throw error ;
161- }
162-
163127export const planCommand = buildCommand ( {
164128 docs : {
165129 brief : "Generate a solution plan using Seer AI" ,
0 commit comments