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 @@ -439,7 +439,15 @@ export class CliContext {
439439 * @returns Promise<string> representing the user's input
440440 */
441441 public async getInput ( config : { message : string ; default ?: string } ) : Promise < string > {
442- return await input ( { message : config . message , default : config . default } ) ;
442+ try {
443+ return await input ( { message : config . message , default : config . default } ) ;
444+ } catch ( error ) {
445+ if ( ( error as Error ) ?. name === "ExitPromptError" ) {
446+ this . logger . info ( "\nCancelled by user." ) ;
447+ throw new TaskAbortSignal ( ) ;
448+ }
449+ throw error ;
450+ }
443451 }
444452}
445453
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