77 CliError ,
88 Finishable ,
99 PosthogEvent ,
10- resolveErrorCode ,
1110 Startable ,
12- shouldReportToSentry ,
1311 TaskAbortSignal ,
1412 TaskContext ,
1513 TaskResult
@@ -19,6 +17,7 @@ import { Workspace } from "@fern-api/workspace-loader";
1917import { input , select } from "@inquirer/prompts" ;
2018import chalk from "chalk" ;
2119import { maxBy } from "lodash-es" ;
20+ import { reportError } from "../telemetry/reportError.js" ;
2221import { SentryClient } from "../telemetry/SentryClient.js" ;
2322import { CliEnvironment } from "./CliEnvironment.js" ;
2423import { StdoutRedirector } from "./StdoutRedirector.js" ;
@@ -127,27 +126,10 @@ export class CliContext {
127126 public failWithoutThrowing ( message ?: string , error ?: unknown , options ?: { code ?: CliError . Code } ) : void {
128127 this . didSucceed = false ;
129128 if ( error instanceof TaskAbortSignal ) {
130- // We already tracked the true error, so we can just return.
131129 return ;
132130 }
133-
134131 logErrorMessage ( { message, error, logger : this . logger } ) ;
135-
136- const code = resolveErrorCode ( error , options ?. code ) ;
137-
138- this . instrumentPostHogEvent ( {
139- command : process . argv . join ( " " ) ,
140- properties : {
141- failed : true ,
142- source : "cli" ,
143- error,
144- errorCode : code
145- }
146- } ) ;
147-
148- if ( shouldReportToSentry ( code ) ) {
149- this . sentryClient . captureException ( error ?? new CliError ( { message : message ?? "" , code } ) , code ) ;
150- }
132+ reportError ( this , error , { ...options , message } ) ;
151133 }
152134
153135 /**
@@ -285,8 +267,8 @@ export class CliContext {
285267 }
286268 }
287269
288- public async captureException ( error : unknown , code ?: CliError . Code ) : Promise < void > {
289- await this . sentryClient . captureException ( error , code ) ;
270+ public captureException ( error : unknown , code ?: CliError . Code ) : void {
271+ this . sentryClient . captureException ( error , code ) ;
290272 }
291273
292274 public readonly logger = createLogger ( ( level , ...args ) => this . log ( level , ...args ) ) ;
0 commit comments