11import { createOrganizationIfDoesNotExist } from "@fern-api/auth" ;
22import { createVenusService } from "@fern-api/core" ;
3- import { TaskAbortSignal } from "@fern-api/task-context" ;
3+ import { CliError } from "@fern-api/task-context" ;
44import type { Argv } from "yargs" ;
55import { TaskContextAdapter } from "../../../context/adapter/TaskContextAdapter.js" ;
66import type { Context } from "../../../context/Context.js" ;
@@ -41,24 +41,32 @@ export class TokenCommand {
4141 response . error . _visit ( {
4242 organizationNotFoundError : ( ) => {
4343 process . stderr . write ( `${ Icons . error } Organization "${ orgId } " was not found.\n` ) ;
44- throw new TaskAbortSignal ( ) ;
44+ throw new CliError ( {
45+ code : CliError . Code . ConfigError
46+ } ) ;
4547 } ,
4648 unauthorizedError : ( ) => {
4749 process . stderr . write ( `${ Icons . error } You do not have access to organization "${ orgId } ".\n` ) ;
48- throw new TaskAbortSignal ( ) ;
50+ throw new CliError ( {
51+ code : CliError . Code . AuthError
52+ } ) ;
4953 } ,
5054 missingOrgPermissionsError : ( ) => {
5155 process . stderr . write (
5256 `${ Icons . error } You do not have the required permissions in organization "${ orgId } ".\n`
5357 ) ;
54- throw new TaskAbortSignal ( ) ;
58+ throw new CliError ( {
59+ code : CliError . Code . AuthError
60+ } ) ;
5561 } ,
5662 _other : ( ) => {
5763 process . stderr . write (
5864 `${ Icons . error } Failed to generate token.\n` +
5965 `\n Please contact support@buildwithfern.com for assistance.\n`
6066 ) ;
61- throw new TaskAbortSignal ( ) ;
67+ throw new CliError ( {
68+ code : CliError . Code . InternalError
69+ } ) ;
6270 }
6371 } ) ;
6472 }
@@ -75,7 +83,7 @@ export class TokenCommand {
7583 `${ Icons . error } No organization specified.\n` +
7684 `\n Run fern init or specify an organization with --org, then run this command again.\n`
7785 ) ;
78- throw new TaskAbortSignal ( ) ;
86+ throw new CliError ( { code : CliError . Code . ConfigError } ) ;
7987 }
8088 }
8189}
0 commit comments