File tree Expand file tree Collapse file tree
cli-v2/src/context/adapter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export class TaskContextAdapter implements TaskContext {
7474 }
7575
7676 public captureException ( error : unknown , code ?: CliError . Code ) : void {
77- const errorCode = resolveErrorCode ( error , code ) ;
77+ const errorCode = resolveErrorCode ( error , code ) ?? "INTERNAL_ERROR" ;
7878 this . context . telemetry . captureException ( error , { errorCode } ) ;
7979 }
8080
Original file line number Diff line number Diff line change @@ -457,7 +457,15 @@ export class CliContext {
457457 * @returns Promise<string> representing the user's input
458458 */
459459 public async getInput ( config : { message : string ; default ?: string } ) : Promise < string > {
460- return await input ( { message : config . message , default : config . default } ) ;
460+ try {
461+ return await input ( { message : config . message , default : config . default } ) ;
462+ } catch ( error ) {
463+ if ( ( error as Error ) ?. name === "ExitPromptError" ) {
464+ this . logger . info ( "\nCancelled by user." ) ;
465+ throw new TaskAbortSignal ( ) ;
466+ }
467+ throw error ;
468+ }
461469 }
462470}
463471
Original file line number Diff line number Diff line change 1+ import { CliError } from "@fern-api/task-context" ;
12import latestVersion from "latest-version" ;
23
34import { CliEnvironment } from "../CliEnvironment.js" ;
@@ -14,7 +15,14 @@ export async function getLatestVersionOfCli({
1415 if ( cliEnvironment . packageName !== "fern-api" || cliEnvironment . packageVersion === "0.0.0" ) {
1516 return cliEnvironment . packageVersion ;
1617 }
17- return latestVersion ( cliEnvironment . packageName , {
18- version : includePreReleases ? "prerelease" : "latest"
19- } ) ;
18+ try {
19+ return await latestVersion ( cliEnvironment . packageName , {
20+ version : includePreReleases ? "prerelease" : "latest"
21+ } ) ;
22+ } catch ( error ) {
23+ throw new CliError ( {
24+ message : `Failed to resolve latest CLI version: ${ error instanceof Error ? error . message : String ( error ) } ` ,
25+ code : CliError . Code . NetworkError
26+ } ) ;
27+ }
2028}
You can’t perform that action at this time.
0 commit comments