@@ -3,7 +3,7 @@ import { createLogger, LOG_LEVELS, LogLevel } from "@fern-api/logger";
33import { getPosthogManager } from "@fern-api/posthog-manager" ;
44import { Project } from "@fern-api/project-loader" ;
55import { isVersionAhead } from "@fern-api/semver-utils" ;
6- import { FernCliError , Finishable , PosthogEvent , Startable , TaskContext , TaskResult } from "@fern-api/task-context" ;
6+ import { Finishable , PosthogEvent , Startable , TaskAbortSignal , TaskContext , TaskResult } from "@fern-api/task-context" ;
77import { Workspace } from "@fern-api/workspace-loader" ;
88import { input , select } from "@inquirer/prompts" ;
99import chalk from "chalk" ;
@@ -95,7 +95,7 @@ export class CliContext {
9595
9696 public failAndThrow ( message ?: string , error ?: unknown ) : never {
9797 this . failWithoutThrowing ( message , error ) ;
98- throw new FernCliError ( ) ;
98+ throw new TaskAbortSignal ( ) ;
9999 }
100100
101101 public failWithoutThrowing ( message ?: string , error ?: unknown ) : void {
@@ -223,13 +223,17 @@ export class CliContext {
223223 try {
224224 result = await run ( context ) ;
225225 } catch ( error ) {
226+ if ( error instanceof TaskAbortSignal ) {
227+ // thrower is responsible for logging, so we generally don't need to log here.
228+ throw error ;
229+ }
226230 if ( ( error as Error ) . message . includes ( "globalThis" ) ) {
227231 context . logger . error ( this . USE_NODE_18_OR_ABOVE_MESSAGE ) ;
228232 context . failWithoutThrowing ( ) ;
229233 } else {
230234 context . failWithoutThrowing ( undefined , error ) ;
231235 }
232- throw new FernCliError ( ) ;
236+ throw new TaskAbortSignal ( ) ;
233237 } finally {
234238 context . finish ( ) ;
235239 }
@@ -398,7 +402,7 @@ export class CliContext {
398402 // User pressed Ctrl+C
399403 if ( ( error as Error ) ?. name === "ExitPromptError" ) {
400404 this . logger . info ( "\nCancelled by user." ) ;
401- throw new FernCliError ( ) ;
405+ throw new TaskAbortSignal ( ) ;
402406 }
403407 throw error ;
404408 }
0 commit comments