@fern-api/fern-api-dev 4.81.1 → 4.82.0-1-g000d7384e60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +996 -358
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -469477,6 +469477,7 @@ var CliError = class _CliError extends Error {
469477
469477
  NetworkError: "NETWORK_ERROR",
469478
469478
  AuthError: "AUTH_ERROR",
469479
469479
  ConfigError: "CONFIG_ERROR",
469480
+ UserError: "USER_ERROR",
469480
469481
  Unclassified: "UNCLASSIFIED"
469481
469482
  };
469482
469483
  })(CliError || (CliError = {}));
@@ -469493,6 +469494,7 @@ var SENTRY_REPORTABLE = {
469493
469494
  [CliError.Code.NetworkError]: false,
469494
469495
  [CliError.Code.AuthError]: false,
469495
469496
  [CliError.Code.ConfigError]: false,
469497
+ [CliError.Code.UserError]: false,
469496
469498
  [CliError.Code.Unclassified]: false
469497
469499
  };
469498
469500
  function shouldReportToSentry(code5) {
@@ -524639,7 +524641,10 @@ function getSchemaFromFernType({ fernType, nameOverride, generatedName, title: t
524639
524641
  string: (value2) => LiteralSchemaValue.string(value2),
524640
524642
  boolean: (value2) => LiteralSchemaValue.boolean(value2),
524641
524643
  _other: () => {
524642
- throw new Error("Unexpected literal type");
524644
+ throw new CliError({
524645
+ message: "Unexpected literal type",
524646
+ code: CliError.Code.InternalError
524647
+ });
524643
524648
  }
524644
524649
  }),
524645
524650
  description,
@@ -527796,7 +527801,10 @@ function convertToReferencedSchema(schema2, breadcrumbs, source2, preserveSchema
527796
527801
  const availability = convertAvailability2(schema2);
527797
527802
  const schemaId = getSchemaIdFromReference(schema2);
527798
527803
  if (schemaId == null) {
527799
- throw new Error(`Invalid schema reference ${JSON.stringify(schema2)}`);
527804
+ throw new CliError({
527805
+ message: `Invalid schema reference ${JSON.stringify(schema2)}`,
527806
+ code: CliError.Code.ReferenceError
527807
+ });
527800
527808
  }
527801
527809
  return Schema.reference({
527802
527810
  // TODO(dsinghvi): references may contain files
@@ -528125,21 +528133,33 @@ var AbstractAsyncAPIParserContext = class {
528125
528133
  */
528126
528134
  resolveSchemaReference(schema2) {
528127
528135
  if (!schema2.$ref.startsWith(SCHEMA_REFERENCE_PREFIX)) {
528128
- throw new Error(`Failed to resolve schema reference: ${schema2.$ref}`);
528136
+ throw new CliError({
528137
+ message: `Failed to resolve schema reference: ${schema2.$ref}`,
528138
+ code: CliError.Code.ReferenceError
528139
+ });
528129
528140
  }
528130
528141
  const schemaKey = schema2.$ref.substring(SCHEMA_REFERENCE_PREFIX.length);
528131
528142
  const splitSchemaKey = schemaKey.split("/");
528132
528143
  const components = this.document.components;
528133
528144
  if (components == null || components.schemas == null) {
528134
- throw new Error("Document does not have components.schemas.");
528145
+ throw new CliError({
528146
+ message: "Document does not have components.schemas.",
528147
+ code: CliError.Code.ReferenceError
528148
+ });
528135
528149
  }
528136
528150
  const [topKey, maybeProps, maybePropKey] = splitSchemaKey;
528137
528151
  if (topKey == null || topKey === "") {
528138
- throw new Error(`${schema2.$ref} cannot be resolved. No schema key provided.`);
528152
+ throw new CliError({
528153
+ message: `${schema2.$ref} cannot be resolved. No schema key provided.`,
528154
+ code: CliError.Code.ReferenceError
528155
+ });
528139
528156
  }
528140
528157
  let resolvedSchema = components.schemas[topKey];
528141
528158
  if (resolvedSchema == null) {
528142
- throw new Error(`Schema "${topKey}" is undefined in document.components.schemas.`);
528159
+ throw new CliError({
528160
+ message: `Schema "${topKey}" is undefined in document.components.schemas.`,
528161
+ code: CliError.Code.ReferenceError
528162
+ });
528143
528163
  }
528144
528164
  if (isReferenceObject(resolvedSchema)) {
528145
528165
  resolvedSchema = this.resolveSchemaReference(resolvedSchema);
@@ -528147,7 +528167,10 @@ var AbstractAsyncAPIParserContext = class {
528147
528167
  if (maybeProps === "properties" && maybePropKey != null) {
528148
528168
  const resolvedProperty = resolvedSchema.properties?.[maybePropKey];
528149
528169
  if (resolvedProperty == null) {
528150
- throw new Error(`Property "${maybePropKey}" not found on "${topKey}". Full ref: ${schema2.$ref}`);
528170
+ throw new CliError({
528171
+ message: `Property "${maybePropKey}" not found on "${topKey}". Full ref: ${schema2.$ref}`,
528172
+ code: CliError.Code.ReferenceError
528173
+ });
528151
528174
  } else if (isReferenceObject(resolvedProperty)) {
528152
528175
  resolvedSchema = this.resolveSchemaReference(resolvedProperty);
528153
528176
  } else {
@@ -528200,12 +528223,15 @@ var AsyncAPIV2ParserContext = class extends AbstractAsyncAPIParserContext {
528200
528223
  const MESSAGE_REFERENCE_PREFIX = "#/components/messages/";
528201
528224
  const components = this.document.components;
528202
528225
  if (components == null || components.messages == null || !message.$ref.startsWith(MESSAGE_REFERENCE_PREFIX)) {
528203
- throw new Error(`Failed to resolve message reference: ${message.$ref} in v2 components`);
528226
+ throw new CliError({
528227
+ message: `Failed to resolve message reference: ${message.$ref} in v2 components`,
528228
+ code: CliError.Code.ReferenceError
528229
+ });
528204
528230
  }
528205
528231
  const messageKey = message.$ref.substring(MESSAGE_REFERENCE_PREFIX.length);
528206
528232
  const resolvedMessage = components.messages[messageKey];
528207
528233
  if (resolvedMessage == null) {
528208
- throw new Error(`${message.$ref} is undefined`);
528234
+ throw new CliError({ message: `${message.$ref} is undefined`, code: CliError.Code.ReferenceError });
528209
528235
  }
528210
528236
  return resolvedMessage;
528211
528237
  }
@@ -529037,7 +529063,10 @@ var ExampleTypeFactory = class _ExampleTypeFactory {
529037
529063
  while (schema2.type === "reference") {
529038
529064
  const resolvedSchema = this.schemas[schema2.schema];
529039
529065
  if (resolvedSchema == null) {
529040
- throw new Error(`Unexpected error: Failed to resolve schema reference: ${schema2.schema}`);
529066
+ throw new CliError({
529067
+ message: `Unexpected error: Failed to resolve schema reference: ${schema2.schema}`,
529068
+ code: CliError.Code.InternalError
529069
+ });
529041
529070
  }
529042
529071
  schema2 = resolvedSchema;
529043
529072
  }
@@ -530366,7 +530395,10 @@ var ExampleWebsocketSessionFactory = class {
530366
530395
  while (schema2.type === "reference") {
530367
530396
  const resolvedSchema = this.schemas[schema2.schema];
530368
530397
  if (resolvedSchema == null) {
530369
- throw new Error(`Unexpected error: Failed to resolve schema reference: ${schema2.schema}`);
530398
+ throw new CliError({
530399
+ message: `Unexpected error: Failed to resolve schema reference: ${schema2.schema}`,
530400
+ code: CliError.Code.InternalError
530401
+ });
530370
530402
  }
530371
530403
  schema2 = resolvedSchema;
530372
530404
  }
@@ -530876,7 +530908,10 @@ var AsyncAPIV3ParserContext = class extends AbstractAsyncAPIParserContext {
530876
530908
  getExampleMessageReference(message) {
530877
530909
  const channelId = message.channelId ?? this.getDefaultChannelId();
530878
530910
  if (channelId == null) {
530879
- throw new Error(`Cannot resolve example message reference: no channelId provided and no channels found in document`);
530911
+ throw new CliError({
530912
+ message: `Cannot resolve example message reference: no channelId provided and no channels found in document`,
530913
+ code: CliError.Code.InternalError
530914
+ });
530880
530915
  }
530881
530916
  return `#/channels/${channelId}/messages/${message.messageId}`;
530882
530917
  }
@@ -530891,12 +530926,12 @@ var AsyncAPIV3ParserContext = class extends AbstractAsyncAPIParserContext {
530891
530926
  resolveParameterReference(parameter6) {
530892
530927
  const PARAMETER_REFERENCE_PREFIX2 = "#/components/parameters/";
530893
530928
  if (this.document.components == null || this.document.components.parameters == null || !parameter6.$ref.startsWith(PARAMETER_REFERENCE_PREFIX2)) {
530894
- throw new Error(`Failed to resolve ${parameter6.$ref}`);
530929
+ throw new CliError({ message: `Failed to resolve ${parameter6.$ref}`, code: CliError.Code.ReferenceError });
530895
530930
  }
530896
530931
  const parameterKey = parameter6.$ref.substring(PARAMETER_REFERENCE_PREFIX2.length);
530897
530932
  const resolvedParameter = this.document.components.parameters[parameterKey];
530898
530933
  if (resolvedParameter == null) {
530899
- throw new Error(`${parameter6.$ref} is undefined`);
530934
+ throw new CliError({ message: `${parameter6.$ref} is undefined`, code: CliError.Code.ReferenceError });
530900
530935
  }
530901
530936
  if ("$ref" in resolvedParameter) {
530902
530937
  return this.resolveParameterReference(resolvedParameter);
@@ -530908,10 +530943,16 @@ var AsyncAPIV3ParserContext = class extends AbstractAsyncAPIParserContext {
530908
530943
  const CHANNELS_PATH_PART = "#/channels/";
530909
530944
  const MESSAGE_REFERENCE_PREFIX = "#/components/messages/";
530910
530945
  if (message == null) {
530911
- throw new Error("Cannot resolve message reference: message is null or undefined");
530946
+ throw new CliError({
530947
+ message: "Cannot resolve message reference: message is null or undefined",
530948
+ code: CliError.Code.InternalError
530949
+ });
530912
530950
  }
530913
530951
  if (!message.$ref) {
530914
- throw new Error("Cannot resolve message reference: message.$ref is undefined or empty");
530952
+ throw new CliError({
530953
+ message: "Cannot resolve message reference: message.$ref is undefined or empty",
530954
+ code: CliError.Code.ReferenceError
530955
+ });
530915
530956
  }
530916
530957
  if (message.$ref.startsWith(CHANNELS_PATH_PART)) {
530917
530958
  const parts = message.$ref.split("/");
@@ -530919,12 +530960,15 @@ var AsyncAPIV3ParserContext = class extends AbstractAsyncAPIParserContext {
530919
530960
  const messageKey2 = parts[4];
530920
530961
  const channelPath = rawChannelPath?.replace(/~1/g, "/").replace(/~0/g, "~");
530921
530962
  if (channelPath == null || messageKey2 == null || !this.document.channels?.[channelPath]) {
530922
- throw new Error(`Failed to resolve message reference ${message.$ref} in channel ${channelPath}`);
530963
+ throw new CliError({
530964
+ message: `Failed to resolve message reference ${message.$ref} in channel ${channelPath}`,
530965
+ code: CliError.Code.ReferenceError
530966
+ });
530923
530967
  }
530924
530968
  const channel3 = this.document.channels[channelPath];
530925
530969
  const resolvedInChannel = channel3.messages?.[messageKey2];
530926
530970
  if (resolvedInChannel == null) {
530927
- throw new Error(`${message.$ref} is undefined`);
530971
+ throw new CliError({ message: `${message.$ref} is undefined`, code: CliError.Code.ReferenceError });
530928
530972
  }
530929
530973
  if ("$ref" in resolvedInChannel && !shallow) {
530930
530974
  return this.resolveMessageReference(resolvedInChannel);
@@ -530937,12 +530981,15 @@ var AsyncAPIV3ParserContext = class extends AbstractAsyncAPIParserContext {
530937
530981
  }
530938
530982
  const components = this.document.components;
530939
530983
  if (!message.$ref.startsWith(MESSAGE_REFERENCE_PREFIX) || !components?.messages) {
530940
- throw new Error(`Failed to resolve message reference: ${message.$ref} in v3 components`);
530984
+ throw new CliError({
530985
+ message: `Failed to resolve message reference: ${message.$ref} in v3 components`,
530986
+ code: CliError.Code.ReferenceError
530987
+ });
530941
530988
  }
530942
530989
  const messageKey = message.$ref.substring(MESSAGE_REFERENCE_PREFIX.length);
530943
530990
  const resolvedInComponents = components.messages[messageKey];
530944
530991
  if (resolvedInComponents == null) {
530945
- throw new Error(`${message.$ref} is undefined`);
530992
+ throw new CliError({ message: `${message.$ref} is undefined`, code: CliError.Code.ReferenceError });
530946
530993
  }
530947
530994
  return {
530948
530995
  ...resolvedInComponents,
@@ -531065,14 +531112,20 @@ function parseAsyncAPIV3({ context: context3, breadcrumbs, source: source2, asyn
531065
531112
  }));
531066
531113
  const channelEvent = channelEvents[channelPath];
531067
531114
  if (channelEvent == null) {
531068
- throw new Error(`Internal error: channelEvents["${channelPath}"] is unexpectedly undefined for operation ${operationId}`);
531115
+ throw new CliError({
531116
+ message: `Internal error: channelEvents["${channelPath}"] is unexpectedly undefined for operation ${operationId}`,
531117
+ code: CliError.Code.InternalError
531118
+ });
531069
531119
  }
531070
531120
  if (operation.action === "receive") {
531071
531121
  channelEvent.subscribe.push(...messagesWithMethodName);
531072
531122
  } else if (operation.action === "send") {
531073
531123
  channelEvent.publish.push(...messagesWithMethodName);
531074
531124
  } else {
531075
- throw new Error(`Operation ${operationId} has an invalid action: ${operation.action}`);
531125
+ throw new CliError({
531126
+ message: `Operation ${operationId} has an invalid action: ${operation.action}`,
531127
+ code: CliError.Code.ValidationError
531128
+ });
531076
531129
  }
531077
531130
  }
531078
531131
  for (const [channelPath, events] of Object.entries(channelEvents)) {
@@ -531336,42 +531389,63 @@ function decodeJsonPointerSegment(segment) {
531336
531389
  }
531337
531390
  function getChannelPathFromOperation(operation) {
531338
531391
  if (!operation.channel) {
531339
- throw new Error("Operation is missing required 'channel' field");
531392
+ throw new CliError({
531393
+ message: "Operation is missing required 'channel' field",
531394
+ code: CliError.Code.ValidationError
531395
+ });
531340
531396
  }
531341
531397
  if (!operation.channel.$ref) {
531342
- throw new Error("Operation channel is missing required '$ref' field");
531398
+ throw new CliError({
531399
+ message: "Operation channel is missing required '$ref' field",
531400
+ code: CliError.Code.ValidationError
531401
+ });
531343
531402
  }
531344
531403
  if (!operation.channel.$ref.startsWith(CHANNEL_REFERENCE_PREFIX)) {
531345
- throw new Error(`Failed to resolve channel path from operation ${operation.channel.$ref}`);
531404
+ throw new CliError({
531405
+ message: `Failed to resolve channel path from operation ${operation.channel.$ref}`,
531406
+ code: CliError.Code.ReferenceError
531407
+ });
531346
531408
  }
531347
531409
  return decodeJsonPointerSegment(operation.channel.$ref.substring(CHANNEL_REFERENCE_PREFIX.length));
531348
531410
  }
531349
531411
  function convertChannelParameterLocation(location2) {
531350
- try {
531351
- const [messageType, parameterKey] = location2.split("#/");
531352
- if (messageType == null || parameterKey == null) {
531353
- throw new Error(`Invalid location format: ${location2}; unable to parse message type and parameter key`);
531354
- }
531355
- if (!messageType.startsWith(LOCATION_PREFIX)) {
531356
- throw new Error(`Invalid location format: ${location2}; expected ${LOCATION_PREFIX} prefix`);
531357
- }
531358
- const type8 = messageType.substring(LOCATION_PREFIX.length);
531359
- if (type8 !== "header" && type8 !== "path" && type8 !== "payload") {
531360
- throw new Error(`Invalid message type: ${type8}. Must be one of: header, path, payload`);
531361
- }
531362
- return { type: type8, parameterKey };
531363
- } catch (error50) {
531364
- throw new Error(`Invalid location format: ${location2}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`);
531412
+ const ASYNCAPI_RUNTIME_EXPRESSION_DOCS = "https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression";
531413
+ const [messageType, parameterKey] = location2.split("#/");
531414
+ if (messageType == null || parameterKey == null) {
531415
+ throw new CliError({
531416
+ message: `Invalid location format: ${location2}; unable to parse message type and parameter key. See ${ASYNCAPI_RUNTIME_EXPRESSION_DOCS} for the expected format.`,
531417
+ code: CliError.Code.ValidationError
531418
+ });
531419
+ }
531420
+ if (!messageType.startsWith(LOCATION_PREFIX)) {
531421
+ throw new CliError({
531422
+ message: `Invalid location format: ${location2}; expected ${LOCATION_PREFIX} prefix`,
531423
+ code: CliError.Code.ValidationError
531424
+ });
531425
+ }
531426
+ const type8 = messageType.substring(LOCATION_PREFIX.length);
531427
+ if (type8 !== "header" && type8 !== "path" && type8 !== "payload") {
531428
+ throw new CliError({
531429
+ message: `Invalid message type: ${type8}. Must be one of: header, path, payload`,
531430
+ code: CliError.Code.ValidationError
531431
+ });
531365
531432
  }
531433
+ return { type: type8, parameterKey };
531366
531434
  }
531367
531435
  function getServerNameFromServerRef(servers, serverRef) {
531368
531436
  if (!serverRef.$ref.startsWith(SERVER_REFERENCE_PREFIX)) {
531369
- throw new Error(`Failed to resolve server name from server ref ${serverRef.$ref}`);
531437
+ throw new CliError({
531438
+ message: `Failed to resolve server name from server ref ${serverRef.$ref}`,
531439
+ code: CliError.Code.ReferenceError
531440
+ });
531370
531441
  }
531371
531442
  const serverName = serverRef.$ref.substring(SERVER_REFERENCE_PREFIX.length);
531372
531443
  const server = servers[serverName];
531373
531444
  if (server == null) {
531374
- throw new Error(`Failed to find server with name ${serverName}`);
531445
+ throw new CliError({
531446
+ message: `Failed to find server with name ${serverName}`,
531447
+ code: CliError.Code.ReferenceError
531448
+ });
531375
531449
  }
531376
531450
  return server;
531377
531451
  }
@@ -531560,7 +531634,7 @@ function convertPaginationExtension(pagination) {
531560
531634
  results: customPagination.results
531561
531635
  });
531562
531636
  }
531563
- throw new Error("Invalid pagination extension");
531637
+ throw new CliError({ message: "Invalid pagination extension", code: CliError.Code.ValidationError });
531564
531638
  }
531565
531639
  function getFernPaginationExtension(document4, operation) {
531566
531640
  const pagination = getExtension(operation, FernOpenAPIExtension.PAGINATION);
@@ -531570,7 +531644,10 @@ function getFernPaginationExtension(document4, operation) {
531570
531644
  if (typeof pagination === "boolean") {
531571
531645
  const topLevelPagination = getExtension(document4, FernOpenAPIExtension.PAGINATION);
531572
531646
  if (typeof topLevelPagination === "boolean") {
531573
- throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");
531647
+ throw new CliError({
531648
+ message: "Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",
531649
+ code: CliError.Code.ValidationError
531650
+ });
531574
531651
  }
531575
531652
  return topLevelPagination == null ? void 0 : convertPaginationExtension(topLevelPagination);
531576
531653
  }
@@ -531889,12 +531966,12 @@ var AbstractOpenAPIV3ParserContext = class {
531889
531966
  }
531890
531967
  resolveParameterReference(parameter6) {
531891
531968
  if (this.document.components == null || this.document.components.parameters == null || !parameter6.$ref.startsWith(PARAMETER_REFERENCE_PREFIX)) {
531892
- throw new Error(`Failed to resolve ${parameter6.$ref}`);
531969
+ throw new CliError({ message: `Failed to resolve ${parameter6.$ref}`, code: CliError.Code.ReferenceError });
531893
531970
  }
531894
531971
  const parameterKey = parameter6.$ref.substring(PARAMETER_REFERENCE_PREFIX.length);
531895
531972
  const resolvedParameter = this.document.components.parameters[parameterKey];
531896
531973
  if (resolvedParameter == null) {
531897
- throw new Error(`${parameter6.$ref} is undefined`);
531974
+ throw new CliError({ message: `${parameter6.$ref} is undefined`, code: CliError.Code.ReferenceError });
531898
531975
  }
531899
531976
  if (isReferenceObject(resolvedParameter)) {
531900
531977
  return this.resolveParameterReference(resolvedParameter);
@@ -531903,12 +531980,15 @@ var AbstractOpenAPIV3ParserContext = class {
531903
531980
  }
531904
531981
  resolveRequestBodyReference(requestBody) {
531905
531982
  if (this.document.components == null || this.document.components.requestBodies == null || !requestBody.$ref.startsWith(REQUEST_BODY_REFERENCE_PREFIX)) {
531906
- throw new Error(`Failed to resolve ${requestBody.$ref}`);
531983
+ throw new CliError({
531984
+ message: `Failed to resolve ${requestBody.$ref}`,
531985
+ code: CliError.Code.ReferenceError
531986
+ });
531907
531987
  }
531908
531988
  const requestBodyKey = requestBody.$ref.substring(REQUEST_BODY_REFERENCE_PREFIX.length);
531909
531989
  const resolvedRequestBody = this.document.components.requestBodies[requestBodyKey];
531910
531990
  if (resolvedRequestBody == null) {
531911
- throw new Error(`${requestBody.$ref} is undefined`);
531991
+ throw new CliError({ message: `${requestBody.$ref} is undefined`, code: CliError.Code.ReferenceError });
531912
531992
  }
531913
531993
  if (isReferenceObject(resolvedRequestBody)) {
531914
531994
  return this.resolveRequestBodyReference(resolvedRequestBody);
@@ -531917,12 +531997,12 @@ var AbstractOpenAPIV3ParserContext = class {
531917
531997
  }
531918
531998
  resolveResponseReference(response) {
531919
531999
  if (this.document.components == null || this.document.components.responses == null || !response.$ref.startsWith(RESPONSE_REFERENCE_PREFIX)) {
531920
- throw new Error(`Failed to resolve ${response.$ref}`);
532000
+ throw new CliError({ message: `Failed to resolve ${response.$ref}`, code: CliError.Code.ReferenceError });
531921
532001
  }
531922
532002
  const parameterKey = response.$ref.substring(RESPONSE_REFERENCE_PREFIX.length);
531923
532003
  const resolvedResponse = this.document.components.responses[parameterKey];
531924
532004
  if (resolvedResponse == null) {
531925
- throw new Error(`${response.$ref} is undefined`);
532005
+ throw new CliError({ message: `${response.$ref} is undefined`, code: CliError.Code.ReferenceError });
531926
532006
  }
531927
532007
  if (isReferenceObject(resolvedResponse)) {
531928
532008
  return this.resolveResponseReference(resolvedResponse);
@@ -531931,12 +532011,12 @@ var AbstractOpenAPIV3ParserContext = class {
531931
532011
  }
531932
532012
  resolveExampleReference(example) {
531933
532013
  if (this.document.components == null || this.document.components.examples == null || !example.$ref.startsWith(EXAMPLES_REFERENCE_PREFIX)) {
531934
- throw new Error(`Failed to resolve ${example.$ref}`);
532014
+ throw new CliError({ message: `Failed to resolve ${example.$ref}`, code: CliError.Code.ReferenceError });
531935
532015
  }
531936
532016
  const parameterKey = example.$ref.substring(EXAMPLES_REFERENCE_PREFIX.length);
531937
532017
  const resolvedExample = this.document.components.examples[parameterKey];
531938
532018
  if (resolvedExample == null) {
531939
- throw new Error(`${example.$ref} is undefined`);
532019
+ throw new CliError({ message: `${example.$ref} is undefined`, code: CliError.Code.ReferenceError });
531940
532020
  }
531941
532021
  if (isReferenceObject(resolvedExample)) {
531942
532022
  return this.resolveExampleReference(resolvedExample);
@@ -531945,12 +532025,15 @@ var AbstractOpenAPIV3ParserContext = class {
531945
532025
  }
531946
532026
  resolveSecuritySchemeReference(securityScheme) {
531947
532027
  if (this.document.components == null || this.document.components.securitySchemes == null || !securityScheme.$ref.startsWith(SECURITY_SCHEME_REFERENCE_PREFIX)) {
531948
- throw new Error(`Failed to resolve ${securityScheme.$ref}`);
532028
+ throw new CliError({
532029
+ message: `Failed to resolve ${securityScheme.$ref}`,
532030
+ code: CliError.Code.ReferenceError
532031
+ });
531949
532032
  }
531950
532033
  const securitySchemeKey = securityScheme.$ref.substring(SECURITY_SCHEME_REFERENCE_PREFIX.length);
531951
532034
  const resolvedSecurityScheme = this.document.components.securitySchemes[securitySchemeKey];
531952
532035
  if (resolvedSecurityScheme == null) {
531953
- throw new Error(`${securityScheme.$ref} is undefined`);
532036
+ throw new CliError({ message: `${securityScheme.$ref} is undefined`, code: CliError.Code.ReferenceError });
531954
532037
  }
531955
532038
  if (isReferenceObject(resolvedSecurityScheme)) {
531956
532039
  return this.resolveSecuritySchemeReference(resolvedSecurityScheme);
@@ -532710,15 +532793,24 @@ function getMultipartPartEncodingFromContentType(contentType) {
532710
532793
  }
532711
532794
  function resolveSchema(schema2, document4) {
532712
532795
  if (!schema2.$ref.startsWith(SCHEMA_REFERENCE_PREFIX)) {
532713
- throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${schema2.$ref}`);
532796
+ throw new CliError({
532797
+ message: `Failed to resolve schema reference because of unsupported prefix: ${schema2.$ref}`,
532798
+ code: CliError.Code.ReferenceError
532799
+ });
532714
532800
  }
532715
532801
  const schemaId = getSchemaIdFromReference(schema2);
532716
532802
  if (schemaId == null) {
532717
- throw new Error(`Failed to resolve schema reference because missing schema id: ${schema2.$ref}`);
532803
+ throw new CliError({
532804
+ message: `Failed to resolve schema reference because missing schema id: ${schema2.$ref}`,
532805
+ code: CliError.Code.ReferenceError
532806
+ });
532718
532807
  }
532719
532808
  const resolvedSchema = document4.components?.schemas?.[schemaId];
532720
532809
  if (resolvedSchema == null) {
532721
- throw new Error(`Failed to resolve schema reference because missing: ${schema2.$ref}`);
532810
+ throw new CliError({
532811
+ message: `Failed to resolve schema reference because missing: ${schema2.$ref}`,
532812
+ code: CliError.Code.ReferenceError
532813
+ });
532722
532814
  }
532723
532815
  if (isReferenceObject(resolvedSchema)) {
532724
532816
  return resolveSchema(resolvedSchema, document4);
@@ -534215,7 +534307,10 @@ function getBasicSecuritySchemeNameAndEnvvar(securityScheme) {
534215
534307
  function convertSecurityScheme(securityScheme, source2, taskContext, context3) {
534216
534308
  if (isReferenceObject(securityScheme)) {
534217
534309
  if (context3 == null) {
534218
- throw new Error(`Converting referenced security schemes requires context: ${JSON.stringify(securityScheme)}`);
534310
+ throw new CliError({
534311
+ message: `Converting referenced security schemes requires context: ${JSON.stringify(securityScheme)}`,
534312
+ code: CliError.Code.InternalError
534313
+ });
534219
534314
  }
534220
534315
  const resolvedSecurityScheme = context3.resolveSecuritySchemeReference(securityScheme);
534221
534316
  return convertSecuritySchemeHelper(resolvedSecurityScheme, source2, taskContext);
@@ -534396,7 +534491,10 @@ function getVariableDefinitions(document4, preserveSchemaIds) {
534396
534491
  }
534397
534492
  ];
534398
534493
  } else {
534399
- throw new Error(`Variable ${variableName} has unsupported schema ${JSON.stringify(schema2)}`);
534494
+ throw new CliError({
534495
+ message: `Variable ${variableName} has unsupported schema ${JSON.stringify(schema2)}`,
534496
+ code: CliError.Code.ValidationError
534497
+ });
534400
534498
  }
534401
534499
  }));
534402
534500
  }
@@ -535712,7 +535810,7 @@ async function validateSchema({ schema: schema2, value: value2, context: context
535712
535810
  });
535713
535811
  });
535714
535812
  const errorMessage = [`Failed to parse file: ${import_path20.default.relative(process.cwd(), filepathBeingParsed)}`, ...issues].join("\n");
535715
- return context3.failAndThrow(errorMessage);
535813
+ return context3.failAndThrow(errorMessage, void 0, { code: CliError.Code.ConfigError });
535716
535814
  }
535717
535815
  function joinZodPath(arr) {
535718
535816
  return arr.reduce((acc, value2) => {
@@ -535745,7 +535843,9 @@ async function convertDependenciesConfiguration({ absolutePathToWorkspace, rawDe
535745
535843
  path: versionOrPath
535746
535844
  };
535747
535845
  } else {
535748
- context3.failWithoutThrowing(`Path to ${coordinate} dependency does not exist: ${pathToApi}`);
535846
+ context3.failWithoutThrowing(`Path to ${coordinate} dependency does not exist: ${pathToApi}`, void 0, {
535847
+ code: CliError.Code.ConfigError
535848
+ });
535749
535849
  }
535750
535850
  } else {
535751
535851
  const unprefixedCoordinate = coordinate.substring(1);
@@ -535760,12 +535860,14 @@ async function convertDependenciesConfiguration({ absolutePathToWorkspace, rawDe
535760
535860
  version: versionOrPath
535761
535861
  };
535762
535862
  } else {
535763
- context3.failWithoutThrowing(`Failed to parse dependency: ${coordinate}`);
535863
+ context3.failWithoutThrowing(`Failed to parse dependency: ${coordinate}`, void 0, {
535864
+ code: CliError.Code.ConfigError
535865
+ });
535764
535866
  }
535765
535867
  }
535766
535868
  }
535767
535869
  if (context3.getResult() === TaskResult.Failure) {
535768
- context3.failAndThrow();
535870
+ context3.failAndThrow(void 0, void 0, { code: CliError.Code.ConfigError });
535769
535871
  }
535770
535872
  return {
535771
535873
  dependencies
@@ -535921,7 +536023,7 @@ function getColorInstanceFromRawConfigOrThrow(raw, context3, key2, theme) {
535921
536023
  }
535922
536024
  const instance = tinycolor(color3);
535923
536025
  if (!instance.isValid()) {
535924
- context3.failAndThrow(`'${typeof raw === "string" ? key2 : `colors.${key2}.${theme}`}' should be a hex color of the format #FFFFFF`);
536026
+ context3.failAndThrow(`'${typeof raw === "string" ? key2 : `colors.${key2}.${theme}`}' should be a hex color of the format #FFFFFF`, void 0, { code: CliError.Code.ConfigError });
535925
536027
  }
535926
536028
  return instance;
535927
536029
  }
@@ -536535,7 +536637,7 @@ async function parseContext7File({ rawPath, absoluteFilepathToDocsConfig, contex
536535
536637
  try {
536536
536638
  JSON.parse(contents);
536537
536639
  } catch (error50) {
536538
- context3.failAndThrow(`Invalid JSON in Context7 config file: ${rawPath}`, error50 instanceof Error ? error50.message : String(error50));
536640
+ context3.failAndThrow(`Invalid JSON in Context7 config file: ${rawPath}`, error50 instanceof Error ? error50.message : String(error50), { code: CliError.Code.ConfigError });
536539
536641
  }
536540
536642
  return absolutePath;
536541
536643
  }
@@ -536695,7 +536797,10 @@ async function getNavigationConfiguration({ tabs, products, versions, navigation
536695
536797
  featureFlags: convertFeatureFlag(product.featureFlag)
536696
536798
  });
536697
536799
  } else {
536698
- throw new Error(`Invalid product configuration: product must have either 'path' or valid 'href' property`);
536800
+ throw new CliError({
536801
+ message: `Invalid product configuration: product must have either 'path' or valid 'href' property`,
536802
+ code: CliError.Code.ConfigError
536803
+ });
536699
536804
  }
536700
536805
  }
536701
536806
  return {
@@ -536710,7 +536815,10 @@ async function getNavigationConfiguration({ tabs, products, versions, navigation
536710
536815
  folderTitleSource
536711
536816
  });
536712
536817
  }
536713
- throw new Error("Unexpected. Docs have neither navigation or versions defined.");
536818
+ throw new CliError({
536819
+ message: "Unexpected. Docs have neither navigation or versions defined.",
536820
+ code: CliError.Code.ConfigError
536821
+ });
536714
536822
  }
536715
536823
  function convertFeatureFlag(flag) {
536716
536824
  if (flag == null) {
@@ -536808,7 +536916,10 @@ function parseWeight(weight) {
536808
536916
  async function convertNavigationTabConfiguration({ tabs, item, absolutePathToFernFolder, absolutePathToConfig, context: context3, folderTitleSource }) {
536809
536917
  const tab2 = tabs[item.tab];
536810
536918
  if (tab2 == null) {
536811
- throw new Error(`Tab ${item.tab} is not defined in the tabs config.`);
536919
+ throw new CliError({
536920
+ message: `Tab ${item.tab} is not defined in the tabs config.`,
536921
+ code: CliError.Code.ConfigError
536922
+ });
536812
536923
  }
536813
536924
  if (tabbedNavigationItemHasVariants(item)) {
536814
536925
  const variants = await Promise.all(item.variants.map(async (variant) => {
@@ -536937,7 +537048,9 @@ var DEFAULT_CHANGELOG_TITLE = "Changelog";
536937
537048
  async function expandFolderConfiguration({ rawConfig, absolutePathToFernFolder, absolutePathToConfig, context: context3, folderTitleSource }) {
536938
537049
  const folderPath = resolveFilepath(rawConfig.folder, absolutePathToConfig);
536939
537050
  if (!await doesPathExist(folderPath)) {
536940
- context3.failAndThrow(`Folder not found: ${rawConfig.folder}`);
537051
+ context3.failAndThrow(`Folder not found: ${rawConfig.folder}`, void 0, {
537052
+ code: CliError.Code.ConfigError
537053
+ });
536941
537054
  }
536942
537055
  validateCollapsibleConfig({
536943
537056
  context: context3,
@@ -537260,7 +537373,10 @@ function parseLibrariesConfiguration(libraries) {
537260
537373
  const result = {};
537261
537374
  for (const [name2, config5] of Object.entries(libraries)) {
537262
537375
  if (!isGitLibraryInput(config5.input)) {
537263
- throw new Error(`Library '${name2}' uses 'path' input which is not yet supported. Please use 'git' input.`);
537376
+ throw new CliError({
537377
+ message: `Library '${name2}' uses 'path' input which is not yet supported. Please use 'git' input.`,
537378
+ code: CliError.Code.ConfigError
537379
+ });
537264
537380
  }
537265
537381
  result[name2] = {
537266
537382
  input: {
@@ -537449,10 +537565,10 @@ function parseAudiences(raw) {
537449
537565
  }
537450
537566
  function validateCollapsibleConfig({ context: context3, sectionTitle, collapsed, collapsible, collapsedByDefault }) {
537451
537567
  if (collapsible != null && collapsed != null) {
537452
- context3.failAndThrow(`Section "${sectionTitle}": cannot use both "collapsible" and the deprecated "collapsed" property. Please use "collapsible" and "collapsed-by-default" instead.`);
537568
+ context3.failAndThrow(`Section "${sectionTitle}": cannot use both "collapsible" and the deprecated "collapsed" property. Please use "collapsible" and "collapsed-by-default" instead.`, void 0, { code: CliError.Code.ConfigError });
537453
537569
  }
537454
537570
  if (collapsedByDefault != null && collapsible !== true) {
537455
- context3.failAndThrow(`Section "${sectionTitle}": "collapsed-by-default" requires "collapsible: true". "collapsed-by-default" has no effect on a non-collapsible section.`);
537571
+ context3.failAndThrow(`Section "${sectionTitle}": "collapsed-by-default" requires "collapsible: true". "collapsed-by-default" has no effect on a non-collapsible section.`, void 0, { code: CliError.Code.ConfigError });
537456
537572
  }
537457
537573
  }
537458
537574
 
@@ -537727,7 +537843,9 @@ function removeDefaultDockerOrgIfPresent(generatorName) {
537727
537843
  function getGeneratorNameOrThrow(generatorName, context3) {
537728
537844
  const normalizedGeneratorName = normalizeGeneratorName(generatorName);
537729
537845
  if (normalizedGeneratorName == null) {
537730
- return context3.failAndThrow("Unrecognized generator: " + generatorName);
537846
+ return context3.failAndThrow("Unrecognized generator: " + generatorName, void 0, {
537847
+ code: CliError.Code.ConfigError
537848
+ });
537731
537849
  }
537732
537850
  return normalizedGeneratorName;
537733
537851
  }
@@ -537854,9 +537972,9 @@ async function updateGeneratorGroup({ generatorsConfiguration, groupName = gener
537854
537972
  const availableGroups = Object.keys(generatorsConfiguration.groups ?? {});
537855
537973
  if (availableGroups.length > 0) {
537856
537974
  const message = "No group specified. Use the --group option:\n" + availableGroups.map((name2) => ` \u203A ${name2}`).join("\n");
537857
- return context3.failAndThrow(message);
537975
+ return context3.failAndThrow(message, void 0, { code: CliError.Code.ConfigError });
537858
537976
  }
537859
- return context3.failAndThrow("No group specified.");
537977
+ return context3.failAndThrow("No group specified.", void 0, { code: CliError.Code.ConfigError });
537860
537978
  }
537861
537979
  const groups2 = generatorsConfiguration.groups ??= {};
537862
537980
  const group = groups2[groupName];
@@ -537880,7 +537998,9 @@ async function addGenerator({ generatorName, generatorsConfiguration, groupName
537880
537998
  context: context3,
537881
537999
  update: async (group) => {
537882
538000
  if (group.generators.some((generator) => addDefaultDockerOrgIfNotPresent("image" in generator ? generator.image.name : generator.name) === normalizedGeneratorName)) {
537883
- context3.failAndThrow(`${generatorName} is already installed in group ${groupName}.`);
538001
+ context3.failAndThrow(`${generatorName} is already installed in group ${groupName}.`, void 0, {
538002
+ code: CliError.Code.ConfigError
538003
+ });
537884
538004
  }
537885
538005
  const latestVersion2 = await getLatestGeneratorVersion({
537886
538006
  cliVersion,
@@ -544443,7 +544563,10 @@ function parseRemoveDiscriminantsFromSchemas(option) {
544443
544563
  } else if (option === "never") {
544444
544564
  return generators_yml_exports.RemoveDiscriminantsFromSchemas.Never;
544445
544565
  }
544446
- throw new Error(`Unknown value for generators.yml API setting: remove-discriminants-from-schemas: ${option}`);
544566
+ throw new CliError({
544567
+ message: `Unknown value for generators.yml API setting: remove-discriminants-from-schemas: ${option}`,
544568
+ code: CliError.Code.ConfigError
544569
+ });
544447
544570
  }
544448
544571
  function mergeSettings(base4, override) {
544449
544572
  return {
@@ -545010,7 +545133,10 @@ async function getGithubLicense({ absolutePathToGeneratorsConfiguration, githubL
545010
545133
  function getGithubPublishInfo(output2, maybeGroupLevelMetadata, maybeTopLevelMetadata) {
545011
545134
  switch (output2.location) {
545012
545135
  case "local-file-system":
545013
- throw new Error("Cannot use local-file-system with github publishing");
545136
+ throw new CliError({
545137
+ message: "Cannot use local-file-system with github publishing",
545138
+ code: CliError.Code.ConfigError
545139
+ });
545014
545140
  case "npm":
545015
545141
  return api_exports4.GithubPublishInfo.npm({
545016
545142
  registryUrl: output2.url ?? "https://registry.npmjs.org",
@@ -545203,7 +545329,10 @@ async function loadRawGeneratorsConfiguration({ absolutePathToWorkspace, context
545203
545329
  if (parsed.ok) {
545204
545330
  return parsed.value;
545205
545331
  }
545206
- throw new Error(parsed.errors.map((e5) => e5.message).join("\n"));
545332
+ throw new CliError({
545333
+ message: parsed.errors.map((e5) => e5.message).join("\n"),
545334
+ code: CliError.Code.ConfigError
545335
+ });
545207
545336
  } catch (e5) {
545208
545337
  if (e5 instanceof jsYaml.YAMLException) {
545209
545338
  const relativePath = import_path24.default.relative(process.cwd(), filepath);
@@ -545225,7 +545354,7 @@ ${e5.mark.snippet}`;
545225
545354
  errorMessage += '\n\nHint: Values starting with "@" (such as scoped npm packages) must be wrapped in quotes.\n Example: package-name: "@scope/package"';
545226
545355
  }
545227
545356
  }
545228
- context3.failAndThrow(errorMessage);
545357
+ context3.failAndThrow(errorMessage, void 0, { code: CliError.Code.ConfigError });
545229
545358
  } else {
545230
545359
  throw e5;
545231
545360
  }
@@ -551709,7 +551838,7 @@ function parseTypeName({ typeName, file: file4 }) {
551709
551838
  imports: file4.imports
551710
551839
  });
551711
551840
  if (reference4 == null) {
551712
- throw new Error("Failed to locate type: " + typeName);
551841
+ throw new CliError({ message: "Failed to locate type: " + typeName, code: CliError.Code.ResolutionError });
551713
551842
  }
551714
551843
  const nameWithoutId = {
551715
551844
  name: file4.casingsGenerator.generateName(reference4.typeName),
@@ -551919,7 +552048,7 @@ function convertHttpRequestBody({ request: request7, file: file4 }) {
551919
552048
  }
551920
552049
  if (isInlineRequestBody(request7.body)) {
551921
552050
  if (request7.name == null) {
551922
- throw new Error("Name is missing for inlined request");
552051
+ throw new CliError({ message: "Name is missing for inlined request", code: CliError.Code.InternalError });
551923
552052
  }
551924
552053
  return HttpRequestBody.inlinedRequestBody({
551925
552054
  name: file4.casingsGenerator.generateName(request7.name),
@@ -552009,13 +552138,19 @@ function getObjectPropertyFromResolvedType({ typeResolver, file: file4, resolved
552009
552138
  default:
552010
552139
  assertNever(resolvedType);
552011
552140
  }
552012
- throw new Error("Internal error; response must be an object in order to return a property as a response");
552141
+ throw new CliError({
552142
+ message: "Internal error; response must be an object in order to return a property as a response",
552143
+ code: CliError.Code.InternalError
552144
+ });
552013
552145
  }
552014
552146
  function getObjectPropertyFromObjectSchema({ typeResolver, file: file4, objectSchema, property: property24 }) {
552015
552147
  const properties7 = getAllPropertiesForRawObjectSchema(objectSchema, file4, typeResolver);
552016
552148
  const objectProperty = properties7[property24];
552017
552149
  if (objectProperty == null) {
552018
- throw new Error(`Object does not have a property named ${property24}.`);
552150
+ throw new CliError({
552151
+ message: `Object does not have a property named ${property24}.`,
552152
+ code: CliError.Code.ReferenceError
552153
+ });
552019
552154
  }
552020
552155
  return objectProperty;
552021
552156
  }
@@ -552048,7 +552183,10 @@ function getAllPropertiesForExtendedType(extendedType, file4, typeResolver) {
552048
552183
  if (resolvedType._type === "named" && isRawObjectDefinition(resolvedType.declaration)) {
552049
552184
  return getAllPropertiesForRawObjectSchema(resolvedType.declaration, file4, typeResolver);
552050
552185
  }
552051
- throw new Error(`Extended type ${extendedType} must be another named type`);
552186
+ throw new CliError({
552187
+ message: `Extended type ${extendedType} must be another named type`,
552188
+ code: CliError.Code.InternalError
552189
+ });
552052
552190
  }
552053
552191
 
552054
552192
  // ../generation/ir-generator/lib/converters/services/convertProperty.js
@@ -552112,7 +552250,10 @@ function getPropertyTypeFromObjectSchema({ typeResolver, file: file4, objectSche
552112
552250
  });
552113
552251
  const propertyType = properties7[property24];
552114
552252
  if (propertyType == null) {
552115
- throw new Error(`Response does not have a property named ${property24}.`);
552253
+ throw new CliError({
552254
+ message: `Response does not have a property named ${property24}.`,
552255
+ code: CliError.Code.ReferenceError
552256
+ });
552116
552257
  }
552117
552258
  return propertyType;
552118
552259
  }
@@ -552153,7 +552294,10 @@ function getAllPropertiesForExtendedType2({ typeResolver, file: file4, extendedT
552153
552294
  objectSchema: resolvedType.declaration
552154
552295
  });
552155
552296
  }
552156
- throw new Error(`Extended type ${extendedType} must be another named type.`);
552297
+ throw new CliError({
552298
+ message: `Extended type ${extendedType} must be another named type.`,
552299
+ code: CliError.Code.InternalError
552300
+ });
552157
552301
  }
552158
552302
  function maybeFileFromResolvedType(resolvedType) {
552159
552303
  if (resolvedType == null) {
@@ -552209,7 +552353,7 @@ function convertHttpSdkRequest({ request: request7, endpointKey, endpoint: endpo
552209
552353
  function convertHttpSdkRequestShape({ service, request: request7, file: file4, typeResolver }) {
552210
552354
  const constructWrapper = () => {
552211
552355
  if (typeof request7 === "string" || request7?.name == null) {
552212
- throw new Error("Name is missing for request wrapper");
552356
+ throw new CliError({ message: "Name is missing for request wrapper", code: CliError.Code.InternalError });
552213
552357
  }
552214
552358
  return SdkRequestShape.wrapper({
552215
552359
  wrapperName: file4.casingsGenerator.generateName(request7.name),
@@ -552389,7 +552533,7 @@ function parseErrorName({ errorName, file: file4 }) {
552389
552533
  imports: file4.imports
552390
552534
  });
552391
552535
  if (reference4 == null) {
552392
- throw new Error("Failed to locate error " + errorName);
552536
+ throw new CliError({ message: "Failed to locate error " + errorName, code: CliError.Code.ResolutionError });
552393
552537
  }
552394
552538
  const nameWithoutId = {
552395
552539
  name: file4.casingsGenerator.generateName(reference4.typeName),
@@ -552859,7 +553003,10 @@ function validateObjectExample({ typeName, typeNameForBreadcrumb, rawObject, fil
552859
553003
  } else {
552860
553004
  const definitionFile = getDefinitionFile(workspace, propertyWithPath.filepathOfDeclaration);
552861
553005
  if (definitionFile == null) {
552862
- throw new Error("Service file does not exist for property: " + propertyWithPath.wireKey);
553006
+ throw new CliError({
553007
+ message: "Service file does not exist for property: " + propertyWithPath.wireKey,
553008
+ code: CliError.Code.InternalError
553009
+ });
552863
553010
  }
552864
553011
  violations.push(...validateTypeReferenceExample({
552865
553012
  rawTypeReference: propertyWithPath.propertyType,
@@ -553334,7 +553481,10 @@ function validatePrimitiveExample({ primitiveType: primitiveType2, example }) {
553334
553481
  base64: () => validateString(example),
553335
553482
  bigInteger: () => validateString(example),
553336
553483
  _other: () => {
553337
- throw new Error("Unknown primitive type v2: " + primitiveType2.v2);
553484
+ throw new CliError({
553485
+ message: "Unknown primitive type v2: " + primitiveType2.v2,
553486
+ code: CliError.Code.InternalError
553487
+ });
553338
553488
  }
553339
553489
  });
553340
553490
  }
@@ -553354,7 +553504,10 @@ function validatePrimitiveExample({ primitiveType: primitiveType2, example }) {
553354
553504
  base64: () => validateString(example),
553355
553505
  bigInteger: () => validateString(example),
553356
553506
  _other: () => {
553357
- throw new Error("Unknown primitive type: " + primitiveType2.v1);
553507
+ throw new CliError({
553508
+ message: "Unknown primitive type: " + primitiveType2.v1,
553509
+ code: CliError.Code.InternalError
553510
+ });
553358
553511
  }
553359
553512
  });
553360
553513
  }
@@ -553577,7 +553730,10 @@ function convertEnumTypeDeclaration({ _enum: _enum3, file: file4 }) {
553577
553730
  if (_enum3.default != null) {
553578
553731
  defaultValue = values2.find((enumValue) => getWireValue(enumValue.name) === _enum3.default);
553579
553732
  if (defaultValue == null) {
553580
- throw new Error(`Default value ${_enum3.default} not found in enum values`);
553733
+ throw new CliError({
553734
+ message: `Default value ${_enum3.default} not found in enum values`,
553735
+ code: CliError.Code.ValidationError
553736
+ });
553581
553737
  }
553582
553738
  }
553583
553739
  return {
@@ -553646,18 +553802,27 @@ function convertTypeExample({ typeName, typeDeclaration: typeDeclaration2, examp
553646
553802
  discriminatedUnion: (rawUnion) => {
553647
553803
  const discriminant21 = getUnionDiscriminant(rawUnion);
553648
553804
  if (!isPlainObject4(example)) {
553649
- throw new Error("Example is not an object");
553805
+ throw new CliError({ message: "Example is not an object", code: CliError.Code.ValidationError });
553650
553806
  }
553651
553807
  const discriminantValueForExample = example[discriminant21];
553652
553808
  if (discriminantValueForExample == null) {
553653
- throw new Error("Example is missing discriminant: " + discriminant21);
553809
+ throw new CliError({
553810
+ message: "Example is missing discriminant: " + discriminant21,
553811
+ code: CliError.Code.ValidationError
553812
+ });
553654
553813
  }
553655
553814
  if (typeof discriminantValueForExample !== "string") {
553656
- throw new Error("Discriminant value is not a string");
553815
+ throw new CliError({
553816
+ message: "Discriminant value is not a string",
553817
+ code: CliError.Code.ValidationError
553818
+ });
553657
553819
  }
553658
553820
  const rawSingleUnionType = rawUnion.union[discriminantValueForExample];
553659
553821
  if (rawSingleUnionType == null) {
553660
- throw new Error(`${discriminantValueForExample} is not one of the specified discriminant values.`);
553822
+ throw new CliError({
553823
+ message: `${discriminantValueForExample} is not one of the specified discriminant values.`,
553824
+ code: CliError.Code.ValidationError
553825
+ });
553661
553826
  }
553662
553827
  const rawValueType = typeof rawSingleUnionType === "string" ? rawSingleUnionType : typeof rawSingleUnionType.type === "string" ? rawSingleUnionType.type : void 0;
553663
553828
  const baseProperties = Object.entries(rawUnion["base-properties"] ?? {}).map(([propertyName, property24]) => {
@@ -553688,7 +553853,10 @@ function convertTypeExample({ typeName, typeDeclaration: typeDeclaration2, examp
553688
553853
  referenceToNamedType: extendedTypeName
553689
553854
  });
553690
553855
  if (resolvedExtendedType._type !== "named" || !isRawObjectDefinition(resolvedExtendedType.declaration)) {
553691
- throw new Error("Extended type is not a named object");
553856
+ throw new CliError({
553857
+ message: "Extended type is not a named object",
553858
+ code: CliError.Code.InternalError
553859
+ });
553692
553860
  }
553693
553861
  const extendedObject = resolvedExtendedType.declaration;
553694
553862
  const propertiesFromExtension = Object.entries(extendedObject.properties ?? {}).map(([propertyName, property24]) => {
@@ -553741,7 +553909,10 @@ function convertTypeExample({ typeName, typeDeclaration: typeDeclaration2, examp
553741
553909
  enum: (rawEnum) => {
553742
553910
  if (typeof example !== "string") {
553743
553911
  const validValues = rawEnum.enum.map((enumEntry) => typeof enumEntry === "string" ? enumEntry : enumEntry.value).join(", ");
553744
- throw new Error(`Expected one of ${validValues}. Received ${example}`);
553912
+ throw new CliError({
553913
+ message: `Expected one of ${validValues}. Received ${example}`,
553914
+ code: CliError.Code.ValidationError
553915
+ });
553745
553916
  }
553746
553917
  return ExampleTypeShape.enum({
553747
553918
  value: fileContainingExample.casingsGenerator.generateNameAndWireValue({
@@ -553782,7 +553953,10 @@ function convertTypeExample({ typeName, typeDeclaration: typeDeclaration2, examp
553782
553953
  return typeof variant === "string" ? variant : variant.type;
553783
553954
  });
553784
553955
  const validValues = variantOptions.join(", ");
553785
- throw new Error(`Expected one of ${validValues}. Received ${example}`);
553956
+ throw new CliError({
553957
+ message: `Expected one of ${validValues}. Received ${example}`,
553958
+ code: CliError.Code.ValidationError
553959
+ });
553786
553960
  }
553787
553961
  });
553788
553962
  }
@@ -553809,7 +553983,7 @@ function convertTypeReferenceExample({ example, fileContainingExample, rawTypeBe
553809
553983
  },
553810
553984
  map: ({ keyType, valueType }) => {
553811
553985
  if (!isPlainObject4(resolvedExample)) {
553812
- throw new Error("Example is not an object");
553986
+ throw new CliError({ message: "Example is not an object", code: CliError.Code.ValidationError });
553813
553987
  }
553814
553988
  const nextContext = { depth: ctx.depth + 1, seenTypeIds: ctx.seenTypeIds };
553815
553989
  return ExampleTypeReferenceShape.container(ExampleContainer.map({
@@ -553841,7 +554015,7 @@ function convertTypeReferenceExample({ example, fileContainingExample, rawTypeBe
553841
554015
  },
553842
554016
  list: (itemType) => {
553843
554017
  if (!Array.isArray(resolvedExample)) {
553844
- throw new Error("Example is not a list");
554018
+ throw new CliError({ message: "Example is not a list", code: CliError.Code.ValidationError });
553845
554019
  }
553846
554020
  const nextContext = { depth: ctx.depth + 1, seenTypeIds: ctx.seenTypeIds };
553847
554021
  return ExampleTypeReferenceShape.container(ExampleContainer.list({
@@ -553860,7 +554034,7 @@ function convertTypeReferenceExample({ example, fileContainingExample, rawTypeBe
553860
554034
  },
553861
554035
  set: (itemType) => {
553862
554036
  if (!Array.isArray(resolvedExample)) {
553863
- throw new Error("Example is not a list");
554037
+ throw new CliError({ message: "Example is not a list", code: CliError.Code.ValidationError });
553864
554038
  }
553865
554039
  const nextContext = { depth: ctx.depth + 1, seenTypeIds: ctx.seenTypeIds };
553866
554040
  return ExampleTypeReferenceShape.container(ExampleContainer.set({
@@ -553930,7 +554104,10 @@ function convertTypeReferenceExample({ example, fileContainingExample, rawTypeBe
553930
554104
  });
553931
554105
  const parsedReferenceToNamedType = fileContainingRawTypeReference.parseTypeReference(named);
553932
554106
  if (parsedReferenceToNamedType.type !== "named") {
553933
- throw new Error("Type reference is not to a named type.");
554107
+ throw new CliError({
554108
+ message: "Type reference is not to a named type.",
554109
+ code: CliError.Code.InternalError
554110
+ });
553934
554111
  }
553935
554112
  const typeName = {
553936
554113
  typeId: parsedReferenceToNamedType.typeId,
@@ -554088,13 +554265,19 @@ function convertPrimitiveExample({ example, typeBeingExemplified }) {
554088
554265
  }));
554089
554266
  },
554090
554267
  _other: () => {
554091
- throw new Error("Unknown primitive type: " + typeBeingExemplified);
554268
+ throw new CliError({
554269
+ message: "Unknown primitive type: " + typeBeingExemplified,
554270
+ code: CliError.Code.InternalError
554271
+ });
554092
554272
  }
554093
554273
  });
554094
554274
  }
554095
554275
  function convertObject4({ typeName, rawObject, example, fileContainingType, fileContainingExample, typeResolver, exampleResolver, workspace, recursionContext }) {
554096
554276
  if (!isPlainObject4(example)) {
554097
- throw new Error(`Example is not an object. Got: ${JSON.stringify(example)}`);
554277
+ throw new CliError({
554278
+ message: `Example is not an object. Got: ${JSON.stringify(example)}`,
554279
+ code: CliError.Code.ValidationError
554280
+ });
554098
554281
  }
554099
554282
  const properties7 = Object.entries(example).map(([wireKey, propertyExample]) => {
554100
554283
  const originalTypeDeclaration = getOriginalTypeDeclarationForProperty({
@@ -554169,7 +554352,10 @@ function getOriginalTypeDeclarationForPropertyFromExtensions({ wirePropertyKey,
554169
554352
  file: file4
554170
554353
  });
554171
554354
  if (resolvedType._type !== "named" || !isRawObjectDefinition(resolvedType.declaration)) {
554172
- throw new Error("Extension is not of a named object");
554355
+ throw new CliError({
554356
+ message: "Extension is not of a named object",
554357
+ code: CliError.Code.InternalError
554358
+ });
554173
554359
  }
554174
554360
  const originalTypeDeclaration = getOriginalTypeDeclarationForProperty({
554175
554361
  wirePropertyKey,
@@ -554206,7 +554392,7 @@ function convertSingleUnionType({ rawValueType, rawSingleUnionType, fileContaini
554206
554392
  switch (parsedSingleUnionTypeProperties.propertiesType) {
554207
554393
  case "singleProperty": {
554208
554394
  if (!isPlainObject4(example)) {
554209
- throw new Error("Example is not an object");
554395
+ throw new CliError({ message: "Example is not an object", code: CliError.Code.ValidationError });
554210
554396
  }
554211
554397
  return {
554212
554398
  wireDiscriminantValue,
@@ -554224,7 +554410,7 @@ function convertSingleUnionType({ rawValueType, rawSingleUnionType, fileContaini
554224
554410
  }
554225
554411
  case "samePropertiesAsObject": {
554226
554412
  if (!isPlainObject4(example)) {
554227
- throw new Error("Example is not an object");
554413
+ throw new CliError({ message: "Example is not an object", code: CliError.Code.ValidationError });
554228
554414
  }
554229
554415
  let rawDeclaration = typeResolver.getDeclarationOfNamedTypeOrThrow({
554230
554416
  referenceToNamedType: rawValueType,
@@ -554237,7 +554423,10 @@ function convertSingleUnionType({ rawValueType, rawSingleUnionType, fileContaini
554237
554423
  });
554238
554424
  }
554239
554425
  if (!isRawObjectDefinition(rawDeclaration.declaration)) {
554240
- throw new Error(`${rawValueType} is not an object`);
554426
+ throw new CliError({
554427
+ message: `${rawValueType} is not an object`,
554428
+ code: CliError.Code.ValidationError
554429
+ });
554241
554430
  }
554242
554431
  const typeName = {
554243
554432
  typeId: parsedSingleUnionTypeProperties.typeId,
@@ -554320,7 +554509,10 @@ function convertExampleEndpointCall2({ service, endpoint: endpoint3, example, ty
554320
554509
  queryParameters: example["query-parameters"] != null ? Object.entries(example["query-parameters"]).map(([wireKey, value2]) => {
554321
554510
  const queryParameterDeclaration = typeof endpoint3.request !== "string" ? endpoint3.request?.["query-parameters"]?.[wireKey] : void 0;
554322
554511
  if (queryParameterDeclaration == null) {
554323
- throw new Error(`Query parameter ${wireKey} does not exist`);
554512
+ throw new CliError({
554513
+ message: `Query parameter ${wireKey} does not exist`,
554514
+ code: CliError.Code.ReferenceError
554515
+ });
554324
554516
  }
554325
554517
  const isAllowMultiple = typeof queryParameterDeclaration !== "string" && queryParameterDeclaration["allow-multiple"] === true;
554326
554518
  const rawType = typeof queryParameterDeclaration === "string" ? queryParameterDeclaration : queryParameterDeclaration.type;
@@ -554429,7 +554621,10 @@ function convertPathParameters({ service, endpoint: endpoint3, example, typeReso
554429
554621
  examplePathParameter
554430
554622
  }));
554431
554623
  } else {
554432
- throw new Error(`Path parameter ${key2} does not exist`);
554624
+ throw new CliError({
554625
+ message: `Path parameter ${key2} does not exist`,
554626
+ code: CliError.Code.ReferenceError
554627
+ });
554433
554628
  }
554434
554629
  }
554435
554630
  }
@@ -554509,7 +554704,10 @@ function convertExampleRequestBody({ endpoint: endpoint3, example, typeResolver,
554509
554704
  return void 0;
554510
554705
  }
554511
554706
  if (!isPlainObject4(example.request)) {
554512
- throw new Error(`Example is not an object. Got: ${JSON.stringify(example.request)}`);
554707
+ throw new CliError({
554708
+ message: `Example is not an object. Got: ${JSON.stringify(example.request)}`,
554709
+ code: CliError.Code.ValidationError
554710
+ });
554513
554711
  }
554514
554712
  const exampleProperties = [];
554515
554713
  const exampleExtraProperties = [];
@@ -554559,7 +554757,10 @@ function convertExampleRequestBody({ endpoint: endpoint3, example, typeResolver,
554559
554757
  });
554560
554758
  continue;
554561
554759
  }
554562
- throw new Error("Could not find original type declaration for property: " + wireKey);
554760
+ throw new CliError({
554761
+ message: "Could not find original type declaration for property: " + wireKey,
554762
+ code: CliError.Code.ResolutionError
554763
+ });
554563
554764
  }
554564
554765
  exampleProperties.push({
554565
554766
  name: file4.casingsGenerator.generateNameAndWireValue({
@@ -554944,7 +555145,7 @@ function getPaginationPropertyComponents(endpointPagination) {
554944
555145
  results: getResponsePropertyComponents(endpointPagination.results)
554945
555146
  };
554946
555147
  }
554947
- throw new Error("Invalid pagination schema");
555148
+ throw new CliError({ message: "Invalid pagination schema", code: CliError.Code.ValidationError });
554948
555149
  }
554949
555150
  function isRawCursorPaginationSchema(rawPaginationSchema) {
554950
555151
  return rawPaginationSchema.cursor != null;
@@ -555115,7 +555316,10 @@ function getTransportForEndpoint({ file: file4, serviceTransport, endpointDeclar
555115
555316
  return void 0;
555116
555317
  }
555117
555318
  if (isHttpService && isGrpcEndpoint) {
555118
- throw new Error("Cannot have a grpc endpoint on an http service");
555319
+ throw new CliError({
555320
+ message: "Cannot have a grpc endpoint on an http service",
555321
+ code: CliError.Code.ValidationError
555322
+ });
555119
555323
  }
555120
555324
  if (isGrpcService && isHttpEndpoint) {
555121
555325
  return Transport.http();
@@ -555129,8 +555333,11 @@ function getTransportForEndpoint({ file: file4, serviceTransport, endpointDeclar
555129
555333
  return createProtobufService(file4, protoSource, sourceResolver, serviceNameOverride);
555130
555334
  }
555131
555335
  }
555132
- throw new Error(`Internal error; failed to determine endpoint transport for
555133
- ${JSON.stringify(endpointDeclaration)}"`);
555336
+ throw new CliError({
555337
+ message: `Internal error; failed to determine endpoint transport for
555338
+ ${JSON.stringify(endpointDeclaration)}"`,
555339
+ code: CliError.Code.InternalError
555340
+ });
555134
555341
  }
555135
555342
  function createProtobufService(file4, source2, sourceResolver, serviceNameOverride) {
555136
555343
  const resolvedSource = sourceResolver.resolveSourceOrThrow({
@@ -555138,14 +555345,20 @@ function createProtobufService(file4, source2, sourceResolver, serviceNameOverri
555138
555345
  relativeFilepath: file4.relativeFilepath
555139
555346
  });
555140
555347
  if (resolvedSource == null || resolvedSource.type !== "protobuf") {
555141
- throw new Error(`Expected a protobuf source for ${source2.proto}.`);
555348
+ throw new CliError({
555349
+ message: `Expected a protobuf source for ${source2.proto}.`,
555350
+ code: CliError.Code.ResolutionError
555351
+ });
555142
555352
  }
555143
555353
  const protobufService = convertProtobufService({
555144
555354
  source: resolvedSource,
555145
555355
  serviceNameOverride
555146
555356
  });
555147
555357
  if (protobufService == null) {
555148
- throw new Error(`Failed to resolve service name from ${resolvedSource.relativeFilePath}.`);
555358
+ throw new CliError({
555359
+ message: `Failed to resolve service name from ${resolvedSource.relativeFilePath}.`,
555360
+ code: CliError.Code.IrConversionError
555361
+ });
555149
555362
  }
555150
555363
  return Transport.grpc({
555151
555364
  service: protobufService
@@ -555357,7 +555570,7 @@ function resolvePathParameterOrThrow({ parameter: parameter6, variableResolver,
555357
555570
  file: file4
555358
555571
  });
555359
555572
  if (resolved == null) {
555360
- throw new Error("Cannot resolve path parameter");
555573
+ throw new CliError({ message: "Cannot resolve path parameter", code: CliError.Code.InternalError });
555361
555574
  }
555362
555575
  return resolved;
555363
555576
  }
@@ -555638,7 +555851,10 @@ var DynamicSnippetsConverter = class {
555638
555851
  return dynamic_exports.Request.body({ pathParameters, body: void 0 });
555639
555852
  }
555640
555853
  if (endpoint3.sdkRequest == null) {
555641
- throw new Error(`Internal error; endpoint "${endpoint3.id}" has a request body but no SDK request`);
555854
+ throw new CliError({
555855
+ message: `Internal error; endpoint "${endpoint3.id}" has a request body but no SDK request`,
555856
+ code: CliError.Code.InternalError
555857
+ });
555642
555858
  }
555643
555859
  switch (endpoint3.sdkRequest.shape.type) {
555644
555860
  case "justRequestBody":
@@ -556131,7 +556347,7 @@ var DynamicSnippetsConverter = class {
556131
556347
  }))
556132
556348
  }),
556133
556349
  _other: () => {
556134
- throw new Error("Unknown environments type");
556350
+ throw new CliError({ message: "Unknown environments type", code: CliError.Code.InternalError });
556135
556351
  }
556136
556352
  })
556137
556353
  };
@@ -556168,10 +556384,16 @@ var DynamicSnippetsConverter = class {
556168
556384
  resolveObjectTypeOrThrow(typeId) {
556169
556385
  const typeDeclaration2 = this.ir.types[typeId];
556170
556386
  if (typeDeclaration2 == null) {
556171
- throw new Error(`Internal error; type "${typeId}" not found`);
556387
+ throw new CliError({
556388
+ message: `Internal error; type "${typeId}" not found`,
556389
+ code: CliError.Code.InternalError
556390
+ });
556172
556391
  }
556173
556392
  if (typeDeclaration2.shape.type !== "object") {
556174
- throw new Error(`Internal error; type "${typeId}" is not an object`);
556393
+ throw new CliError({
556394
+ message: `Internal error; type "${typeId}" is not an object`,
556395
+ code: CliError.Code.InternalError
556396
+ });
556175
556397
  }
556176
556398
  return typeDeclaration2.shape;
556177
556399
  }
@@ -556456,7 +556678,10 @@ function convertOAuthClientCredentials({ propertyResolver, endpointResolver, typ
556456
556678
  tokenEndpoint
556457
556679
  });
556458
556680
  if (oauthTokenEndpoint == null) {
556459
- throw new Error("Failed to convert OAuth token endpoint.");
556681
+ throw new CliError({
556682
+ message: "Failed to convert OAuth token endpoint.",
556683
+ code: CliError.Code.IrConversionError
556684
+ });
556460
556685
  }
556461
556686
  const refreshEndpoint = refreshTokenEndpoint != null ? convertOAuthRefreshEndpoint({
556462
556687
  propertyResolver,
@@ -556634,7 +556859,7 @@ function convertSchemeReference2({ reference: reference4, authSchemeDeclarations
556634
556859
  const convertNamedAuthSchemeReference = (reference5, docs2) => {
556635
556860
  const declaration = authSchemeDeclarations?.[reference5];
556636
556861
  if (declaration == null) {
556637
- throw new Error("Unknown auth scheme: " + reference5);
556862
+ throw new CliError({ message: "Unknown auth scheme: " + reference5, code: CliError.Code.ReferenceError });
556638
556863
  }
556639
556864
  return visitRawAuthSchemeDeclaration(declaration, {
556640
556865
  header: (rawHeader) => AuthScheme.header({
@@ -556746,7 +556971,10 @@ function generateOAuth({ key: key2, file: file4, docs: docs2, rawScheme, propert
556746
556971
  }))
556747
556972
  });
556748
556973
  default:
556749
- throw new Error(`Unknown OAuth type: '${rawScheme?.type}'`);
556974
+ throw new CliError({
556975
+ message: `Unknown OAuth type: '${rawScheme?.type}'`,
556976
+ code: CliError.Code.ValidationError
556977
+ });
556750
556978
  }
556751
556979
  }
556752
556980
  function generateInferredAuth({ key: key2, file: file4, docs: docs2, rawScheme, propertyResolver, endpointResolver }) {
@@ -557010,7 +557238,10 @@ function convertChannel({ channel: channel3, typeResolver, exampleResolver, vari
557010
557238
  queryParameters: example["query-parameters"] != null ? Object.entries(example["query-parameters"]).map(([wireKey, value2]) => {
557011
557239
  const queryParameterDeclaration = channel3["query-parameters"]?.[wireKey];
557012
557240
  if (queryParameterDeclaration == null) {
557013
- throw new Error(`Query parameter ${wireKey} does not exist`);
557241
+ throw new CliError({
557242
+ message: `Query parameter ${wireKey} does not exist`,
557243
+ code: CliError.Code.ReferenceError
557244
+ });
557014
557245
  }
557015
557246
  return {
557016
557247
  name: file4.casingsGenerator.generateNameAndWireValue({
@@ -557035,7 +557266,10 @@ function convertChannel({ channel: channel3, typeResolver, exampleResolver, vari
557035
557266
  messages: example.messages.map((messageExample) => {
557036
557267
  const message = channel3.messages?.[messageExample.type];
557037
557268
  if (message == null) {
557038
- throw new Error(`Message ${messageExample.type} does not exist`);
557269
+ throw new CliError({
557270
+ message: `Message ${messageExample.type} does not exist`,
557271
+ code: CliError.Code.ReferenceError
557272
+ });
557039
557273
  }
557040
557274
  return {
557041
557275
  type: messageExample.type,
@@ -557074,7 +557308,7 @@ function convertExampleWebSocketMessageBody({ message, example, typeResolver, ex
557074
557308
  }));
557075
557309
  }
557076
557310
  if (!isPlainObject4(example)) {
557077
- throw new Error("Example must be an object");
557311
+ throw new CliError({ message: "Example must be an object", code: CliError.Code.ValidationError });
557078
557312
  }
557079
557313
  const exampleProperties = [];
557080
557314
  for (const [wireKey, propertyExample] of Object.entries(example)) {
@@ -557104,7 +557338,10 @@ function convertExampleWebSocketMessageBody({ message, example, typeResolver, ex
557104
557338
  file: file4
557105
557339
  });
557106
557340
  if (originalTypeDeclaration == null) {
557107
- throw new Error("Could not find original type declaration for property: " + wireKey);
557341
+ throw new CliError({
557342
+ message: "Could not find original type declaration for property: " + wireKey,
557343
+ code: CliError.Code.ResolutionError
557344
+ });
557108
557345
  }
557109
557346
  exampleProperties.push({
557110
557347
  name: file4.casingsGenerator.generateNameAndWireValue({
@@ -557188,7 +557425,10 @@ function convertChannelPathParameters({ channel: channel3, example, typeResolver
557188
557425
  examplePathParameter
557189
557426
  }));
557190
557427
  } else {
557191
- throw new Error(`Path parameter ${key2} does not exist`);
557428
+ throw new CliError({
557429
+ message: `Path parameter ${key2} does not exist`,
557430
+ code: CliError.Code.ReferenceError
557431
+ });
557192
557432
  }
557193
557433
  }
557194
557434
  }
@@ -557339,7 +557579,10 @@ var ReadmeEndpointCache = class {
557339
557579
  getEndpointForReadmeOrThrow(readmeEndpoint) {
557340
557580
  const endpoint3 = this.getEndpointForReadme(readmeEndpoint);
557341
557581
  if (endpoint3 == null) {
557342
- throw new Error(`Endpoint not found for ${JSON.stringify(readmeEndpoint)}`);
557582
+ throw new CliError({
557583
+ message: `Endpoint not found for ${JSON.stringify(readmeEndpoint)}`,
557584
+ code: CliError.Code.ResolutionError
557585
+ });
557343
557586
  }
557344
557587
  return endpoint3;
557345
557588
  }
@@ -557387,7 +557630,7 @@ function getReadmeEndpointObject({ endpoint: endpoint3 }) {
557387
557630
  if (typeof endpoint3 === "string") {
557388
557631
  const split2 = endpoint3.split(" ");
557389
557632
  if (split2.length !== 2 || split2[0] == null || split2[1] == null) {
557390
- throw new Error(`invalid endpoint string: ${endpoint3}`);
557633
+ throw new CliError({ message: `invalid endpoint string: ${endpoint3}`, code: CliError.Code.ParseError });
557391
557634
  }
557392
557635
  return {
557393
557636
  method: split2[0],
@@ -557484,7 +557727,10 @@ function convertWebhookExamples2({ webhook, examples, file: file4, typeResolver,
557484
557727
  }));
557485
557728
  }
557486
557729
  if (!isPlainObject4(webhook.payload)) {
557487
- throw new Error(`Example webhook payload is not an object. Got: ${JSON.stringify(webhook.payload)}`);
557730
+ throw new CliError({
557731
+ message: `Example webhook payload is not an object. Got: ${JSON.stringify(webhook.payload)}`,
557732
+ code: CliError.Code.ValidationError
557733
+ });
557488
557734
  }
557489
557735
  return examples.map((example) => ({
557490
557736
  docs: webhook.docs,
@@ -557876,7 +558122,10 @@ function convertGenericTypeDeclaration({ generic, file: file4, typeResolver }) {
557876
558122
  const genericInstantiation = typeof generic === "string" ? generic : generic.type;
557877
558123
  const maybeGeneric = parseGeneric(genericInstantiation);
557878
558124
  if (maybeGeneric == null) {
557879
- throw new Error(`Invalid generic type definition: ${genericInstantiation}`);
558125
+ throw new CliError({
558126
+ message: `Invalid generic type definition: ${genericInstantiation}`,
558127
+ code: CliError.Code.ValidationError
558128
+ });
557880
558129
  }
557881
558130
  const resolvedBaseGeneric = typeResolver.getDeclarationOfNamedTypeOrThrow({
557882
558131
  referenceToNamedType: genericInstantiation,
@@ -557907,7 +558156,10 @@ function convertGenericTypeDeclaration({ generic, file: file4, typeResolver }) {
557907
558156
  extendedProperties: void 0
557908
558157
  });
557909
558158
  }
557910
- throw new Error(`Generic type definition not supported: ${genericInstantiation}`);
558159
+ throw new CliError({
558160
+ message: `Generic type definition not supported: ${genericInstantiation}`,
558161
+ code: CliError.Code.ValidationError
558162
+ });
557911
558163
  }
557912
558164
 
557913
558165
  // ../generation/ir-generator/lib/converters/type-declarations/convertAliasTypeDeclaration.js
@@ -558299,7 +558551,10 @@ var PackageTreeGenerator = class {
558299
558551
  addPackageRedirection({ from: from4, to: to10 }) {
558300
558552
  const package_ = this.getPackageForFernFilepath(from4);
558301
558553
  if (package_.navigationConfig != null) {
558302
- throw new Error("Found duplicate navigationConfig for package");
558554
+ throw new CliError({
558555
+ message: "Found duplicate navigationConfig for package",
558556
+ code: CliError.Code.InternalError
558557
+ });
558303
558558
  }
558304
558559
  package_.navigationConfig = {
558305
558560
  pointsTo: IdGenerator.generateSubpackageId(to10)
@@ -558308,7 +558563,7 @@ var PackageTreeGenerator = class {
558308
558563
  addDocs(fernFilepath, docs2) {
558309
558564
  const package_ = this.getPackageForFernFilepath(fernFilepath);
558310
558565
  if (package_.docs != null) {
558311
- throw new Error("Found duplicate docs for package");
558566
+ throw new CliError({ message: "Found duplicate docs for package", code: CliError.Code.InternalError });
558312
558567
  }
558313
558568
  package_.docs = docs2;
558314
558569
  }
@@ -558324,21 +558579,30 @@ var PackageTreeGenerator = class {
558324
558579
  addService(serviceId, service) {
558325
558580
  const package_ = this.getPackageForFernFilepath(service.name.fernFilepath);
558326
558581
  if (package_.service != null) {
558327
- throw new Error("Found duplicate service for " + serviceId);
558582
+ throw new CliError({
558583
+ message: "Found duplicate service for " + serviceId,
558584
+ code: CliError.Code.InternalError
558585
+ });
558328
558586
  }
558329
558587
  package_.service = serviceId;
558330
558588
  }
558331
558589
  addWebhookGroup(webhookGroupId, fernFilepath) {
558332
558590
  const package_ = this.getPackageForFernFilepath(fernFilepath);
558333
558591
  if (package_.webhooks != null) {
558334
- throw new Error("Found duplicate webhook group for " + webhookGroupId);
558592
+ throw new CliError({
558593
+ message: "Found duplicate webhook group for " + webhookGroupId,
558594
+ code: CliError.Code.InternalError
558595
+ });
558335
558596
  }
558336
558597
  package_.webhooks = webhookGroupId;
558337
558598
  }
558338
558599
  addWebSocketChannel(websocketChannelId, fernFilepath) {
558339
558600
  const package_ = this.getPackageForFernFilepath(fernFilepath);
558340
558601
  if (package_.webhooks != null) {
558341
- throw new Error("Found duplicate webhook group for " + websocketChannelId);
558602
+ throw new CliError({
558603
+ message: "Found duplicate webhook group for " + websocketChannelId,
558604
+ code: CliError.Code.InternalError
558605
+ });
558342
558606
  }
558343
558607
  package_.websocket = websocketChannelId;
558344
558608
  }
@@ -558381,24 +558645,33 @@ var PackageTreeGenerator = class {
558381
558645
  }
558382
558646
  sortRootPackage(subpackagesInOrder) {
558383
558647
  if (!isEqualIgnoreOrder(this.rootPackage.subpackages, subpackagesInOrder)) {
558384
- throw new Error("Sorted subpackages differ from unsorted packages in root");
558648
+ throw new CliError({
558649
+ message: "Sorted subpackages differ from unsorted packages in root",
558650
+ code: CliError.Code.InternalError
558651
+ });
558385
558652
  }
558386
558653
  this.rootPackage.subpackages = subpackagesInOrder;
558387
558654
  }
558388
558655
  sortSubpackage(subpackageId, subpackagesInOrder) {
558389
558656
  const subpackage = this.subpackages[subpackageId];
558390
558657
  if (subpackage == null) {
558391
- throw new Error("Subpackage does not exist: " + subpackageId);
558658
+ throw new CliError({
558659
+ message: "Subpackage does not exist: " + subpackageId,
558660
+ code: CliError.Code.ResolutionError
558661
+ });
558392
558662
  }
558393
558663
  if (!isEqualIgnoreOrder(subpackage.subpackages, subpackagesInOrder)) {
558394
- throw new Error("Sorted subpackages differ from unsorted packages");
558664
+ throw new CliError({
558665
+ message: "Sorted subpackages differ from unsorted packages",
558666
+ code: CliError.Code.InternalError
558667
+ });
558395
558668
  }
558396
558669
  subpackage.subpackages = subpackagesInOrder;
558397
558670
  }
558398
558671
  getAllSubpackagesWithEndpoints(root6) {
558399
558672
  const subpackage = this.subpackages[root6];
558400
558673
  if (subpackage == null) {
558401
- throw new Error("Subpackage does not exist: " + root6);
558674
+ throw new CliError({ message: "Subpackage does not exist: " + root6, code: CliError.Code.ResolutionError });
558402
558675
  }
558403
558676
  const subpackagesWithEndpoints = this.getAllChildrenWithEndpoints(subpackage);
558404
558677
  if (subpackagesWithEndpoints.length > 0 || subpackage.service != null) {
@@ -558419,7 +558692,10 @@ var PackageTreeGenerator = class {
558419
558692
  const subpackagesInParent = parent.subpackages.map((subpackageId) => {
558420
558693
  const subpackage = this.subpackages[subpackageId];
558421
558694
  if (subpackage == null) {
558422
- throw new Error("Subpackage ID is invalid: " + subpackageId);
558695
+ throw new CliError({
558696
+ message: "Subpackage ID is invalid: " + subpackageId,
558697
+ code: CliError.Code.InternalError
558698
+ });
558423
558699
  }
558424
558700
  return subpackage;
558425
558701
  });
@@ -558498,7 +558774,10 @@ var EndpointResolverImpl = class {
558498
558774
  resolveEndpointOrThrow({ endpoint: endpoint3, file: file4 }) {
558499
558775
  const resolvedEndpoint = this.resolveEndpoint({ endpoint: endpoint3, file: file4 });
558500
558776
  if (resolvedEndpoint == null) {
558501
- throw new Error("Cannot resolve endpoint: " + endpoint3 + " in file " + file4.relativeFilepath);
558777
+ throw new CliError({
558778
+ message: "Cannot resolve endpoint: " + endpoint3 + " in file " + file4.relativeFilepath,
558779
+ code: CliError.Code.ResolutionError
558780
+ });
558502
558781
  }
558503
558782
  return resolvedEndpoint;
558504
558783
  }
@@ -558626,7 +558905,10 @@ var ErrorResolverImpl = class {
558626
558905
  getDeclarationOrThrow(referenceToError, file4) {
558627
558906
  const declaration = this.getDeclaration(referenceToError, file4);
558628
558907
  if (declaration == null) {
558629
- throw new Error("Error does not exist: " + referenceToError);
558908
+ throw new CliError({
558909
+ message: "Error does not exist: " + referenceToError,
558910
+ code: CliError.Code.ResolutionError
558911
+ });
558630
558912
  }
558631
558913
  return declaration;
558632
558914
  }
@@ -558712,7 +558994,7 @@ var ExampleResolverImpl = class {
558712
558994
  resolveAllReferencesInExampleOrThrow({ example, file: file4 }) {
558713
558995
  const resolvedExample = this.resolveAllReferencesInExample({ example, file: file4 });
558714
558996
  if (resolvedExample == null) {
558715
- throw new Error("Failed to resolve examples");
558997
+ throw new CliError({ message: "Failed to resolve examples", code: CliError.Code.ResolutionError });
558716
558998
  }
558717
558999
  return resolvedExample;
558718
559000
  }
@@ -558759,7 +559041,7 @@ var ExampleResolverImpl = class {
558759
559041
  resolveExampleOrThrow({ example, file: file4 }) {
558760
559042
  const resolvedExample = this.resolveExample({ example, file: file4 });
558761
559043
  if (resolvedExample == null) {
558762
- throw new Error("Cannot resolve example: " + example);
559044
+ throw new CliError({ message: "Cannot resolve example: " + example, code: CliError.Code.ResolutionError });
558763
559045
  }
558764
559046
  return resolvedExample;
558765
559047
  }
@@ -558810,7 +559092,10 @@ var PropertyResolverImpl = class {
558810
559092
  resolveRequestPropertyOrThrow({ file: file4, endpoint: endpoint3, propertyComponents }) {
558811
559093
  const resolvedRequestProperty = this.resolveRequestProperty({ file: file4, endpoint: endpoint3, propertyComponents });
558812
559094
  if (resolvedRequestProperty == null) {
558813
- throw new Error("Cannot resolve request property from endpoint: " + endpoint3 + " in file " + file4.relativeFilepath);
559095
+ throw new CliError({
559096
+ message: "Cannot resolve request property from endpoint: " + endpoint3 + " in file " + file4.relativeFilepath,
559097
+ code: CliError.Code.ResolutionError
559098
+ });
558814
559099
  }
558815
559100
  return resolvedRequestProperty;
558816
559101
  }
@@ -558854,7 +559139,10 @@ var PropertyResolverImpl = class {
558854
559139
  resolveResponsePropertyOrThrow({ file: file4, endpoint: endpoint3, propertyComponents }) {
558855
559140
  const resolvedResponseProperty = this.resolveResponseProperty({ file: file4, endpoint: endpoint3, propertyComponents });
558856
559141
  if (resolvedResponseProperty == null) {
558857
- throw new Error("Cannot resolve response property from endpoint: " + endpoint3 + " in file " + file4.relativeFilepath);
559142
+ throw new CliError({
559143
+ message: "Cannot resolve response property from endpoint: " + endpoint3 + " in file " + file4.relativeFilepath,
559144
+ code: CliError.Code.ResolutionError
559145
+ });
558858
559146
  }
558859
559147
  return resolvedResponseProperty;
558860
559148
  }
@@ -559021,7 +559309,10 @@ var PropertyResolverImpl = class {
559021
559309
  propertyComponents: breadcrumbs
559022
559310
  });
559023
559311
  if (!currentType) {
559024
- throw new Error(`Cannot find property '${breadcrumbs.join(".")}' in inline request body in file ${file4.relativeFilepath}`);
559312
+ throw new CliError({
559313
+ message: `Cannot find property '${breadcrumbs.join(".")}' in inline request body in file ${file4.relativeFilepath}`,
559314
+ code: CliError.Code.InternalError
559315
+ });
559025
559316
  }
559026
559317
  result.push({
559027
559318
  name: file4.casingsGenerator.generateName(component),
@@ -559039,7 +559330,10 @@ function getNestedObjectPropertyTypeOrThrow({ typeResolver, file: file4, resolve
559039
559330
  propertyName
559040
559331
  });
559041
559332
  if (!nestedPropertyType) {
559042
- throw new Error(`Cannot find property '${breadcrumbs.join(".")}' in ${rootTypeLabel}`);
559333
+ throw new CliError({
559334
+ message: `Cannot find property '${breadcrumbs.join(".")}' in ${rootTypeLabel}`,
559335
+ code: CliError.Code.InternalError
559336
+ });
559043
559337
  }
559044
559338
  return nestedPropertyType;
559045
559339
  }
@@ -559216,14 +559510,20 @@ var TypeResolverImpl = class {
559216
559510
  resolveTypeOrThrow({ type: type8, file: file4 }) {
559217
559511
  const resolvedType = this.resolveType({ type: type8, file: file4 });
559218
559512
  if (resolvedType == null) {
559219
- throw new Error("Cannot resolve type: " + type8 + " in file " + file4.relativeFilepath);
559513
+ throw new CliError({
559514
+ message: "Cannot resolve type: " + type8 + " in file " + file4.relativeFilepath,
559515
+ code: CliError.Code.ResolutionError
559516
+ });
559220
559517
  }
559221
559518
  return resolvedType;
559222
559519
  }
559223
559520
  getDeclarationOfNamedTypeOrThrow({ referenceToNamedType, file: file4 }) {
559224
559521
  const declaration = this.getDeclarationOfNamedType({ referenceToNamedType, file: file4 });
559225
559522
  if (declaration == null) {
559226
- throw new Error("Cannot find declaration of type: " + referenceToNamedType + " in file " + file4.relativeFilepath);
559523
+ throw new CliError({
559524
+ message: "Cannot find declaration of type: " + referenceToNamedType + " in file " + file4.relativeFilepath,
559525
+ code: CliError.Code.ResolutionError
559526
+ });
559227
559527
  }
559228
559528
  return declaration;
559229
559529
  }
@@ -559366,7 +559666,10 @@ var TypeResolverImpl = class {
559366
559666
  resolveNamedTypeOrThrow({ referenceToNamedType, file: file4 }) {
559367
559667
  const resolvedType = this.resolveNamedType({ referenceToNamedType, file: file4 });
559368
559668
  if (resolvedType == null) {
559369
- throw new Error("Cannot resolve type: " + referenceToNamedType);
559669
+ throw new CliError({
559670
+ message: "Cannot resolve type: " + referenceToNamedType,
559671
+ code: CliError.Code.ResolutionError
559672
+ });
559370
559673
  }
559371
559674
  return resolvedType;
559372
559675
  }
@@ -559425,7 +559728,10 @@ var VariableResolverImpl = class _VariableResolverImpl {
559425
559728
  getDeclarationOrThrow(referenceToVariable, file4) {
559426
559729
  const declaration = this.getDeclaration(referenceToVariable, file4);
559427
559730
  if (declaration == null) {
559428
- throw new Error("Variable does not exist: " + referenceToVariable);
559731
+ throw new CliError({
559732
+ message: "Variable does not exist: " + referenceToVariable,
559733
+ code: CliError.Code.ResolutionError
559734
+ });
559429
559735
  }
559430
559736
  return declaration;
559431
559737
  }
@@ -559448,7 +559754,10 @@ var VariableResolverImpl = class _VariableResolverImpl {
559448
559754
  getVariableIdOrThrow(referenceToVariable) {
559449
559755
  const variableId = this.getVariableId(referenceToVariable);
559450
559756
  if (variableId == null) {
559451
- throw new Error("Variable reference does not start with " + _VariableResolverImpl.VARIABLE_PREFIX);
559757
+ throw new CliError({
559758
+ message: "Variable reference does not start with " + _VariableResolverImpl.VARIABLE_PREFIX,
559759
+ code: CliError.Code.ResolutionError
559760
+ });
559452
559761
  }
559453
559762
  return variableId;
559454
559763
  }
@@ -559620,7 +559929,10 @@ function generateIntermediateRepresentation({ workspace, generationLanguage, key
559620
559929
  }
559621
559930
  const errorDiscriminationSchema = workspace.definition.rootApiFile.contents["error-discrimination"];
559622
559931
  if (errorDiscriminationSchema == null) {
559623
- throw new Error("error-discrimination is missing in api.yml but there are declared errors.");
559932
+ throw new CliError({
559933
+ message: "error-discrimination is missing in api.yml but there are declared errors.",
559934
+ code: CliError.Code.ConfigError
559935
+ });
559624
559936
  }
559625
559937
  for (const [errorName, errorDeclaration] of Object.entries(errors4)) {
559626
559938
  const convertedErrorDeclaration = convertErrorDeclaration({
@@ -581572,7 +581884,9 @@ function getPathToLocalStorageDependency(dependency) {
581572
581884
  }
581573
581885
  async function validateLocalDependencyAndGetDefinition({ dependency, context: context3, cliVersion, settings, loadAPIWorkspace: loadAPIWorkspace2 }) {
581574
581886
  if (loadAPIWorkspace2 == null) {
581575
- context3.failWithoutThrowing("Failed to load api definition");
581887
+ context3.failWithoutThrowing("Failed to load api definition", void 0, {
581888
+ code: CliError.Code.ResolutionError
581889
+ });
581576
581890
  return void 0;
581577
581891
  }
581578
581892
  context3.logger.info("Parsing...");
@@ -581583,7 +581897,9 @@ async function validateLocalDependencyAndGetDefinition({ dependency, context: co
581583
581897
  workspaceName: void 0
581584
581898
  });
581585
581899
  if (!loadDependencyWorkspaceResult.didSucceed) {
581586
- context3.failWithoutThrowing("Failed to load api definition", loadDependencyWorkspaceResult.failures);
581900
+ context3.failWithoutThrowing("Failed to load api definition", loadDependencyWorkspaceResult.failures, {
581901
+ code: CliError.Code.ResolutionError
581902
+ });
581587
581903
  return void 0;
581588
581904
  }
581589
581905
  context3.logger.info("Modifying source filepath ...");
@@ -581605,16 +581921,24 @@ async function validateVersionedDependencyAndGetDefinition({ dependency, context
581605
581921
  if (!response.ok) {
581606
581922
  response.error._visit({
581607
581923
  orgDoesNotExistError: () => {
581608
- context3.failWithoutThrowing("Organization does not exist");
581924
+ context3.failWithoutThrowing("Organization does not exist", void 0, {
581925
+ code: CliError.Code.ResolutionError
581926
+ });
581609
581927
  },
581610
581928
  apiDoesNotExistError: () => {
581611
- context3.failWithoutThrowing("API does not exist");
581929
+ context3.failWithoutThrowing("API does not exist", void 0, {
581930
+ code: CliError.Code.ResolutionError
581931
+ });
581612
581932
  },
581613
581933
  versionDoesNotExistError: () => {
581614
- context3.failWithoutThrowing("Version does not exist");
581934
+ context3.failWithoutThrowing("Version does not exist", void 0, {
581935
+ code: CliError.Code.ResolutionError
581936
+ });
581615
581937
  },
581616
581938
  _other: (error50) => {
581617
- context3.failWithoutThrowing("Failed to download API manifest", error50);
581939
+ context3.failWithoutThrowing("Failed to download API manifest", error50, {
581940
+ code: CliError.Code.NetworkError
581941
+ });
581618
581942
  }
581619
581943
  });
581620
581944
  return void 0;
@@ -581624,14 +581948,14 @@ async function validateVersionedDependencyAndGetDefinition({ dependency, context
581624
581948
  const parsedCliVersionOfDependency = parseVersion(response.body.cliVersion);
581625
581949
  if (parsedYamlVersionOfDependency != null) {
581626
581950
  if (parsedYamlVersionOfDependency > YAML_SCHEMA_VERSION) {
581627
- context3.failWithoutThrowing(`${dependency.organization}/${dependency.apiName}@${dependency.version} on a higher version of fern. Upgrade this workspace to ${response.body.cliVersion}`);
581951
+ context3.failWithoutThrowing(`${dependency.organization}/${dependency.apiName}@${dependency.version} on a higher version of fern. Upgrade this workspace to ${response.body.cliVersion}`, void 0, { code: CliError.Code.VersionError });
581628
581952
  return void 0;
581629
581953
  } else if (parsedYamlVersionOfDependency < YAML_SCHEMA_VERSION) {
581630
- context3.failWithoutThrowing(`${dependency.organization}/${dependency.apiName}@${dependency.version} on a lower version of fern. Upgrade it to ${cliVersion}`);
581954
+ context3.failWithoutThrowing(`${dependency.organization}/${dependency.apiName}@${dependency.version} on a lower version of fern. Upgrade it to ${cliVersion}`, void 0, { code: CliError.Code.VersionError });
581631
581955
  return void 0;
581632
581956
  }
581633
581957
  } else if (parsedCliVersion.major !== parsedCliVersionOfDependency.major || parsedCliVersion.minor !== parsedCliVersionOfDependency.minor) {
581634
- context3.failWithoutThrowing(`CLI version is ${response.body.cliVersion}. Expected ${parsedCliVersion.major}.${parsedCliVersion.minor}.x (to match current workspace).`);
581958
+ context3.failWithoutThrowing(`CLI version is ${response.body.cliVersion}. Expected ${parsedCliVersion.major}.${parsedCliVersion.minor}.x (to match current workspace).`, void 0, { code: CliError.Code.VersionError });
581635
581959
  return void 0;
581636
581960
  }
581637
581961
  context3.logger.info("Downloading...");
@@ -581643,7 +581967,9 @@ async function validateVersionedDependencyAndGetDefinition({ dependency, context
581643
581967
  absolutePathToLocalOutput: pathToDefinition
581644
581968
  });
581645
581969
  } catch (error50) {
581646
- context3.failWithoutThrowing("Failed to download API", error50);
581970
+ context3.failWithoutThrowing("Failed to download API", error50, {
581971
+ code: CliError.Code.NetworkError
581972
+ });
581647
581973
  return void 0;
581648
581974
  }
581649
581975
  metadata = response.body;
@@ -581653,7 +581979,9 @@ async function validateVersionedDependencyAndGetDefinition({ dependency, context
581653
581979
  }
581654
581980
  context3.logger.info("Parsing...");
581655
581981
  if (loadAPIWorkspace2 == null) {
581656
- context3.failWithoutThrowing("Failed to load API");
581982
+ context3.failWithoutThrowing("Failed to load API", void 0, {
581983
+ code: CliError.Code.ResolutionError
581984
+ });
581657
581985
  return void 0;
581658
581986
  }
581659
581987
  const loadDependencyWorkspaceResult = await loadAPIWorkspace2({
@@ -581663,12 +581991,14 @@ async function validateVersionedDependencyAndGetDefinition({ dependency, context
581663
581991
  workspaceName: void 0
581664
581992
  });
581665
581993
  if (!loadDependencyWorkspaceResult.didSucceed) {
581666
- context3.failWithoutThrowing("Failed to parse dependency after downloading", loadDependencyWorkspaceResult.failures);
581994
+ context3.failWithoutThrowing("Failed to parse dependency after downloading", loadDependencyWorkspaceResult.failures, { code: CliError.Code.ParseError });
581667
581995
  return void 0;
581668
581996
  }
581669
581997
  const workspaceOfDependency = loadDependencyWorkspaceResult.workspace;
581670
581998
  if (workspaceOfDependency.type === "oss") {
581671
- context3.failWithoutThrowing("Dependency must be a fern workspace.");
581999
+ context3.failWithoutThrowing("Dependency must be a fern workspace.", void 0, {
582000
+ code: CliError.Code.ConfigError
582001
+ });
581672
582002
  return void 0;
581673
582003
  }
581674
582004
  return await loadDependencyWorkspaceResult.workspace.getDefinition({ context: context3 }, settings);
@@ -592208,7 +592538,9 @@ var LazyFernWorkspace = class extends AbstractAPIWorkspace {
592208
592538
  const parseResult = await parseYamlFiles(yamlFiles);
592209
592539
  if (!parseResult.didSucceed) {
592210
592540
  handleFailedWorkspaceParserResultRaw(parseResult.failures, defaultedContext.logger);
592211
- return defaultedContext.failAndThrow();
592541
+ return defaultedContext.failAndThrow(void 0, void 0, {
592542
+ code: CliError.Code.ValidationError
592543
+ });
592212
592544
  }
592213
592545
  const structuralValidationResult = validateStructureOfYamlFiles({
592214
592546
  files: parseResult.files,
@@ -592217,7 +592549,9 @@ var LazyFernWorkspace = class extends AbstractAPIWorkspace {
592217
592549
  });
592218
592550
  if (!structuralValidationResult.didSucceed) {
592219
592551
  handleFailedWorkspaceParserResultRaw(structuralValidationResult.failures, defaultedContext.logger);
592220
- return defaultedContext.failAndThrow();
592552
+ return defaultedContext.failAndThrow(void 0, void 0, {
592553
+ code: CliError.Code.ValidationError
592554
+ });
592221
592555
  }
592222
592556
  const processPackageMarkersResult = await processPackageMarkers({
592223
592557
  dependenciesConfiguration,
@@ -592229,7 +592563,9 @@ var LazyFernWorkspace = class extends AbstractAPIWorkspace {
592229
592563
  });
592230
592564
  if (!processPackageMarkersResult.didSucceed) {
592231
592565
  handleFailedWorkspaceParserResultRaw(processPackageMarkersResult.failures, defaultedContext.logger);
592232
- return defaultedContext.failAndThrow();
592566
+ return defaultedContext.failAndThrow(void 0, void 0, {
592567
+ code: CliError.Code.ValidationError
592568
+ });
592233
592569
  }
592234
592570
  let definition3 = {
592235
592571
  absoluteFilePath: absolutePathToDefinition,
@@ -592296,7 +592632,9 @@ async function mergeWithOverrides2({ absoluteFilePathToOverrides, data: data2, c
592296
592632
  parsedOverrides = jsYaml.load(contents, { json: true });
592297
592633
  }
592298
592634
  } catch (err) {
592299
- return context3.failAndThrow(`Failed to read overrides from file ${absoluteFilePathToOverrides}`);
592635
+ return context3.failAndThrow(`Failed to read overrides from file ${absoluteFilePathToOverrides}`, void 0, {
592636
+ code: CliError.Code.ParseError
592637
+ });
592300
592638
  }
592301
592639
  return mergeWithOverrides({ data: data2, overrides: parsedOverrides, allowNullKeys });
592302
592640
  }
@@ -592456,7 +592794,10 @@ async function resolveExternalRefs(obj, baseDir, mainFileAbsPath, registry2, app
592456
592794
  }
592457
592795
  const cacheKey = `${absoluteRefPath}#${jsonPointer}`;
592458
592796
  if (visited.has(cacheKey)) {
592459
- throw new Error(`Circular $ref detected: "${ref2}" (resolved to "${cacheKey}")`);
592797
+ throw new CliError({
592798
+ message: `Circular $ref detected: "${ref2}" (resolved to "${cacheKey}")`,
592799
+ code: CliError.Code.ReferenceError
592800
+ });
592460
592801
  }
592461
592802
  const newVisited = new Set(visited);
592462
592803
  newVisited.add(cacheKey);
@@ -592539,7 +592880,9 @@ async function parseOverlayFile(absoluteFilePathToOverlay, context3) {
592539
592880
  try {
592540
592881
  contents = await (0, import_promises26.readFile)(absoluteFilePathToOverlay, "utf8");
592541
592882
  } catch (err) {
592542
- return context3.failAndThrow(`Failed to read overlay file at ${absoluteFilePathToOverlay}: ${err}`);
592883
+ return context3.failAndThrow(`Failed to read overlay file at ${absoluteFilePathToOverlay}: ${err}`, void 0, {
592884
+ code: CliError.Code.ConfigError
592885
+ });
592543
592886
  }
592544
592887
  try {
592545
592888
  try {
@@ -592548,7 +592891,9 @@ async function parseOverlayFile(absoluteFilePathToOverlay, context3) {
592548
592891
  return jsYaml.load(contents, { json: true });
592549
592892
  }
592550
592893
  } catch (err) {
592551
- return context3.failAndThrow(`Failed to parse overlay file at ${absoluteFilePathToOverlay}: ${err}`);
592894
+ return context3.failAndThrow(`Failed to parse overlay file at ${absoluteFilePathToOverlay}: ${err}`, void 0, {
592895
+ code: CliError.Code.ParseError
592896
+ });
592552
592897
  }
592553
592898
  }
592554
592899
  function validateOverlay(overlay, context3) {
@@ -604748,7 +605093,7 @@ function getPlatformInfo() {
604748
605093
  osName = "Windows";
604749
605094
  break;
604750
605095
  default:
604751
- throw new Error(`Unsupported platform: ${platform3}`);
605096
+ throw new CliError({ message: `Unsupported platform: ${platform3}`, code: CliError.Code.EnvironmentError });
604752
605097
  }
604753
605098
  let archName;
604754
605099
  switch (arch3) {
@@ -604759,7 +605104,7 @@ function getPlatformInfo() {
604759
605104
  archName = platform3 === "linux" ? "aarch64" : "arm64";
604760
605105
  break;
604761
605106
  default:
604762
- throw new Error(`Unsupported architecture: ${arch3}`);
605107
+ throw new CliError({ message: `Unsupported architecture: ${arch3}`, code: CliError.Code.EnvironmentError });
604763
605108
  }
604764
605109
  return {
604765
605110
  os: osName,
@@ -604833,7 +605178,10 @@ async function acquireLock(logger4) {
604833
605178
  await new Promise((resolve14) => setTimeout(resolve14, LOCK_RETRY_INTERVAL_MS));
604834
605179
  }
604835
605180
  }
604836
- throw new Error(`Failed to acquire buf lock after timeout and retry`);
605181
+ throw new CliError({
605182
+ message: `Failed to acquire buf lock after timeout and retry`,
605183
+ code: CliError.Code.InternalError
605184
+ });
604837
605185
  }
604838
605186
  return createLockReleaser(lockPath, logger4);
604839
605187
  }
@@ -605022,7 +605370,10 @@ async function ensureBufCommand(logger4) {
605022
605370
  logger4.debug(`Using auto-downloaded buf: ${downloadedBufPath}`);
605023
605371
  return downloadedBufPath;
605024
605372
  }
605025
- throw new Error("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').");
605373
+ throw new CliError({
605374
+ message: "Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').",
605375
+ code: CliError.Code.EnvironmentError
605376
+ });
605026
605377
  }
605027
605378
  }
605028
605379
  var PROTOBUF_GENERATOR_CONFIG_FILENAME = "buf.gen.yaml";
@@ -605239,7 +605590,7 @@ var ProtobufIRGenerator = class {
605239
605590
  try {
605240
605591
  await (0, import_promises34.access)(bufLockPath);
605241
605592
  } catch {
605242
- this.context.failAndThrow("Air-gapped mode requires a pre-cached buf.lock file. Please run 'buf dep update' at build time to cache dependencies.");
605593
+ this.context.failAndThrow("Air-gapped mode requires a pre-cached buf.lock file. Please run 'buf dep update' at build time to cache dependencies.", void 0, { code: CliError.Code.InternalError });
605243
605594
  }
605244
605595
  } else {
605245
605596
  await buf(["dep", "update"]);
@@ -605247,7 +605598,9 @@ var ProtobufIRGenerator = class {
605247
605598
  }
605248
605599
  const bufGenerateResult = await buf(["generate"]);
605249
605600
  if (bufGenerateResult.exitCode !== 0) {
605250
- this.context.failAndThrow(bufGenerateResult.stderr);
605601
+ this.context.failAndThrow(bufGenerateResult.stderr, void 0, {
605602
+ code: CliError.Code.IrConversionError
605603
+ });
605251
605604
  }
605252
605605
  await (0, import_promises34.unlink)(bufYamlPath);
605253
605606
  } catch (error50) {
@@ -605263,11 +605616,15 @@ var ProtobufIRGenerator = class {
605263
605616
  try {
605264
605617
  this.resolvedBufCommand = await ensureBufCommand(this.context.logger);
605265
605618
  } catch (error50) {
605266
- this.context.failAndThrow(error50 instanceof Error ? error50.message : String(error50));
605619
+ this.context.failAndThrow(error50 instanceof Error ? error50.message : String(error50), void 0, {
605620
+ code: CliError.Code.EnvironmentError
605621
+ });
605267
605622
  }
605268
605623
  }
605269
605624
  async generateRemote() {
605270
- this.context.failAndThrow("Remote Protobuf generation is unimplemented.");
605625
+ this.context.failAndThrow("Remote Protobuf generation is unimplemented.", void 0, {
605626
+ code: CliError.Code.InternalError
605627
+ });
605271
605628
  }
605272
605629
  };
605273
605630
 
@@ -605307,7 +605664,7 @@ function getPlatformInfo2() {
605307
605664
  osName = "windows";
605308
605665
  break;
605309
605666
  default:
605310
- throw new Error(`Unsupported platform: ${platform3}`);
605667
+ throw new CliError({ message: `Unsupported platform: ${platform3}`, code: CliError.Code.EnvironmentError });
605311
605668
  }
605312
605669
  let archName;
605313
605670
  switch (arch3) {
@@ -605318,7 +605675,7 @@ function getPlatformInfo2() {
605318
605675
  archName = "arm64";
605319
605676
  break;
605320
605677
  default:
605321
- throw new Error(`Unsupported architecture: ${arch3}`);
605678
+ throw new CliError({ message: `Unsupported architecture: ${arch3}`, code: CliError.Code.EnvironmentError });
605322
605679
  }
605323
605680
  return {
605324
605681
  os: osName,
@@ -605392,7 +605749,10 @@ async function acquireLock2(logger4) {
605392
605749
  await new Promise((resolve14) => setTimeout(resolve14, LOCK_RETRY_INTERVAL_MS2));
605393
605750
  }
605394
605751
  }
605395
- throw new Error(`Failed to acquire lock after timeout and retry`);
605752
+ throw new CliError({
605753
+ message: `Failed to acquire lock after timeout and retry`,
605754
+ code: CliError.Code.InternalError
605755
+ });
605396
605756
  }
605397
605757
  return createLockReleaser2(lockPath, logger4);
605398
605758
  }
@@ -605510,7 +605870,9 @@ var ProtobufOpenAPIGenerator = class {
605510
605870
  */
605511
605871
  async prepare({ absoluteFilepathToProtobufRoot, relativeFilepathToProtobufRoot, local, deps }) {
605512
605872
  if (!local) {
605513
- this.context.failAndThrow("Remote Protobuf generation is unimplemented.");
605873
+ this.context.failAndThrow("Remote Protobuf generation is unimplemented.", void 0, {
605874
+ code: CliError.Code.InternalError
605875
+ });
605514
605876
  }
605515
605877
  await this.ensureBufResolved();
605516
605878
  await this.ensureProtocGenOpenAPIResolved();
@@ -605530,7 +605892,7 @@ var ProtobufOpenAPIGenerator = class {
605530
605892
  try {
605531
605893
  await (0, import_promises36.access)(bufLockPath);
605532
605894
  } catch {
605533
- this.context.failAndThrow("Air-gapped mode requires a pre-cached buf.lock file. Please run 'buf dep update' at build time to cache dependencies.");
605895
+ this.context.failAndThrow("Air-gapped mode requires a pre-cached buf.lock file. Please run 'buf dep update' at build time to cache dependencies.", void 0, { code: CliError.Code.InternalError });
605534
605896
  }
605535
605897
  } else {
605536
605898
  const bufCommand = this.resolvedBufCommand ?? "buf";
@@ -605567,7 +605929,9 @@ var ProtobufOpenAPIGenerator = class {
605567
605929
  });
605568
605930
  const bufGenerateResult = await buf(["generate", target.toString()]);
605569
605931
  if (bufGenerateResult.exitCode !== 0) {
605570
- this.context.failAndThrow(bufGenerateResult.stderr);
605932
+ this.context.failAndThrow(bufGenerateResult.stderr, void 0, {
605933
+ code: CliError.Code.IrConversionError
605934
+ });
605571
605935
  }
605572
605936
  const outputPath = join8(preparedDir.cwd, RelativeFilePath2.of(PROTOBUF_GENERATOR_OUTPUT_FILEPATH2));
605573
605937
  const uniqueOutput = AbsoluteFilePath2.of((await import_tmp_promise7.default.file({ postfix: ".yaml" })).path);
@@ -605625,7 +605989,7 @@ var ProtobufOpenAPIGenerator = class {
605625
605989
  try {
605626
605990
  await (0, import_promises36.access)(bufLockPath);
605627
605991
  } catch {
605628
- this.context.failAndThrow("Air-gapped mode requires a pre-cached buf.lock file. Please run 'buf dep update' at build time to cache dependencies.");
605992
+ this.context.failAndThrow("Air-gapped mode requires a pre-cached buf.lock file. Please run 'buf dep update' at build time to cache dependencies.", void 0, { code: CliError.Code.InternalError });
605629
605993
  }
605630
605994
  } else {
605631
605995
  await buf(["dep", "update"]);
@@ -605638,7 +606002,9 @@ var ProtobufOpenAPIGenerator = class {
605638
606002
  }
605639
606003
  const bufGenerateResult = await buf(["generate", target.toString()]);
605640
606004
  if (bufGenerateResult.exitCode !== 0) {
605641
- this.context.failAndThrow(bufGenerateResult.stderr);
606005
+ this.context.failAndThrow(bufGenerateResult.stderr, void 0, {
606006
+ code: CliError.Code.IrConversionError
606007
+ });
605642
606008
  }
605643
606009
  if (cleanupBufLock) {
605644
606010
  await (0, import_promises36.unlink)(bufLockPath);
@@ -605676,7 +606042,7 @@ var ProtobufOpenAPIGenerator = class {
605676
606042
  this.protocGenOpenAPIResolved = true;
605677
606043
  return;
605678
606044
  } catch {
605679
- this.context.failAndThrow("FERN_USE_LOCAL_PROTOC_GEN_OPENAPI is set but protoc-gen-openapi was not found on PATH.");
606045
+ this.context.failAndThrow("FERN_USE_LOCAL_PROTOC_GEN_OPENAPI is set but protoc-gen-openapi was not found on PATH.", void 0, { code: CliError.Code.EnvironmentError });
605680
606046
  }
605681
606047
  }
605682
606048
  this.context.logger.debug("Resolving protoc-gen-openapi (preferring auto-downloaded fern fork)");
@@ -605701,7 +606067,7 @@ var ProtobufOpenAPIGenerator = class {
605701
606067
  }
605702
606068
  this.protocGenOpenAPIResolved = true;
605703
606069
  } catch {
605704
- this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/fern-api/protoc-gen-openapi/cmd/protoc-gen-openapi@latest').");
606070
+ this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/fern-api/protoc-gen-openapi/cmd/protoc-gen-openapi@latest').", void 0, { code: CliError.Code.EnvironmentError });
605705
606071
  }
605706
606072
  }
605707
606073
  async ensureBufResolved() {
@@ -605711,11 +606077,15 @@ var ProtobufOpenAPIGenerator = class {
605711
606077
  try {
605712
606078
  this.resolvedBufCommand = await ensureBufCommand(this.context.logger);
605713
606079
  } catch (error50) {
605714
- this.context.failAndThrow(error50 instanceof Error ? error50.message : String(error50));
606080
+ this.context.failAndThrow(error50 instanceof Error ? error50.message : String(error50), void 0, {
606081
+ code: CliError.Code.EnvironmentError
606082
+ });
605715
606083
  }
605716
606084
  }
605717
606085
  async generateRemote() {
605718
- this.context.failAndThrow("Remote Protobuf generation is unimplemented.");
606086
+ this.context.failAndThrow("Remote Protobuf generation is unimplemented.", void 0, {
606087
+ code: CliError.Code.InternalError
606088
+ });
605719
606089
  }
605720
606090
  };
605721
606091
  function getProtobufGeneratorConfig({ relativeFilepathToProtobufRoot }) {
@@ -606094,7 +606464,10 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
606094
606464
  }
606095
606465
  }
606096
606466
  if (mergedIr === void 0) {
606097
- throw new Error("Failed to generate intermediate representation");
606467
+ throw new CliError({
606468
+ message: "Failed to generate intermediate representation",
606469
+ code: CliError.Code.IrConversionError
606470
+ });
606098
606471
  }
606099
606472
  if (authOverrides != null) {
606100
606473
  mergedIr = resolveOAuthEndpointReferences({ ir: mergedIr, authOverrides });
@@ -606190,7 +606563,10 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
606190
606563
  }
606191
606564
  async convertSpecsOverrideToSpecs(specsOverride) {
606192
606565
  if (!Array.isArray(specsOverride)) {
606193
- throw new Error("Conjure specs override is not yet supported");
606566
+ throw new CliError({
606567
+ message: "Conjure specs override is not yet supported",
606568
+ code: CliError.Code.InternalError
606569
+ });
606194
606570
  }
606195
606571
  const specs = [];
606196
606572
  for (const spec of specsOverride) {
@@ -606224,7 +606600,10 @@ var OSSWorkspace = class _OSSWorkspace extends BaseOpenAPIWorkspace {
606224
606600
  };
606225
606601
  specs.push(openApiSpec);
606226
606602
  } else {
606227
- throw new Error(`Spec type override not yet supported. Only OpenAPI specs are currently supported in specs override.`);
606603
+ throw new CliError({
606604
+ message: `Spec type override not yet supported. Only OpenAPI specs are currently supported in specs override.`,
606605
+ code: CliError.Code.InternalError
606606
+ });
606228
606607
  }
606229
606608
  }
606230
606609
  return specs;
@@ -614356,7 +614735,7 @@ var AccessTokenPosthogManager = class {
614356
614735
  properties: {
614357
614736
  ...event,
614358
614737
  ...event.properties,
614359
- version: "4.81.1",
614738
+ version: "4.82.0-1-g000d7384e60",
614360
614739
  usingAccessToken: true
614361
614740
  }
614362
614741
  });
@@ -614410,7 +614789,7 @@ var UserPosthogManager = class {
614410
614789
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
614411
614790
  event: "CLI",
614412
614791
  properties: {
614413
- version: "4.81.1",
614792
+ version: "4.82.0-1-g000d7384e60",
614414
614793
  ...event,
614415
614794
  ...event.properties,
614416
614795
  usingAccessToken: false,
@@ -615614,7 +615993,10 @@ var PlatformKeyring = class {
615614
615993
  await this.setPasswordWindows(service, account, password);
615615
615994
  break;
615616
615995
  default:
615617
- throw new Error(`Unsupported platform: ${process.platform}`);
615996
+ throw new CliError({
615997
+ message: `Unsupported platform: ${process.platform}`,
615998
+ code: CliError.Code.EnvironmentError
615999
+ });
615618
616000
  }
615619
616001
  }
615620
616002
  async getPassword(service, account) {
@@ -615626,7 +616008,10 @@ var PlatformKeyring = class {
615626
616008
  case "win32":
615627
616009
  return this.getPasswordWindows(service, account);
615628
616010
  default:
615629
- throw new Error(`Unsupported platform: ${process.platform}`);
616011
+ throw new CliError({
616012
+ message: `Unsupported platform: ${process.platform}`,
616013
+ code: CliError.Code.EnvironmentError
616014
+ });
615630
616015
  }
615631
616016
  }
615632
616017
  async deletePassword(service, account) {
@@ -615638,7 +616023,10 @@ var PlatformKeyring = class {
615638
616023
  case "win32":
615639
616024
  return this.deletePasswordWindows(service, account);
615640
616025
  default:
615641
- throw new Error(`Unsupported platform: ${process.platform}`);
616026
+ throw new CliError({
616027
+ message: `Unsupported platform: ${process.platform}`,
616028
+ code: CliError.Code.EnvironmentError
616029
+ });
615642
616030
  }
615643
616031
  }
615644
616032
  async findCredentials(service) {
@@ -615650,7 +616038,10 @@ var PlatformKeyring = class {
615650
616038
  case "win32":
615651
616039
  return this.findCredentialsWindows(service);
615652
616040
  default:
615653
- throw new Error(`Unsupported platform: ${process.platform}`);
616041
+ throw new CliError({
616042
+ message: `Unsupported platform: ${process.platform}`,
616043
+ code: CliError.Code.EnvironmentError
616044
+ });
615654
616045
  }
615655
616046
  }
615656
616047
  async setPasswordDarwin(service, account, password) {
@@ -617763,7 +618154,10 @@ var FileFinder = class {
617763
618154
  async findOrThrow({ filename, remediationMessage }) {
617764
618155
  const filepath = await this.find({ filename });
617765
618156
  if (filepath == null) {
617766
- throw new Error(`${filename} file not found in any parent directory from ${this.from}`);
618157
+ throw new CliError({
618158
+ message: `${filename} file not found in any parent directory from ${this.from}`,
618159
+ code: CliError.Code.InternalError
618160
+ });
617767
618161
  }
617768
618162
  return filepath;
617769
618163
  }
@@ -617805,7 +618199,10 @@ var FernYmlSchemaLoader = class {
617805
618199
  async loadOrThrow() {
617806
618200
  const loadResult = await this.load();
617807
618201
  if (loadResult.type === "notFound") {
617808
- throw new Error(`${FILENAME2} file not found in any parent directory; did you forget to run \`fern init\`?`);
618202
+ throw new CliError({
618203
+ message: `${FILENAME2} file not found in any parent directory; did you forget to run \`fern init\`?`,
618204
+ code: CliError.Code.InternalError
618205
+ });
617809
618206
  }
617810
618207
  if (loadResult.type === "failure") {
617811
618208
  throw new SourcedValidationError(loadResult.issues);
@@ -617876,7 +618273,10 @@ var TelemetryClient = class _TelemetryClient {
617876
618273
  if (sentryDsn != null && sentryDsn.length > 0 && isTelemetryEnabled) {
617877
618274
  const sentryEnvironment = "development";
617878
618275
  if (sentryEnvironment == null || sentryEnvironment.length === 0) {
617879
- throw new Error("SENTRY_ENVIRONMENT must be set when SENTRY_DSN is configured");
618276
+ throw new CliError({
618277
+ message: "SENTRY_ENVIRONMENT must be set when SENTRY_DSN is configured",
618278
+ code: CliError.Code.ConfigError
618279
+ });
617880
618280
  }
617881
618281
  this.sentry = init2({
617882
618282
  dsn: sentryDsn,
@@ -617994,7 +618394,7 @@ var TelemetryClient = class _TelemetryClient {
617994
618394
  return join8(AbsoluteFilePath2.of((0, import_os8.homedir)()), RelativeFilePath2.of(".fern"), RelativeFilePath2.of("id"));
617995
618395
  }
617996
618396
  /**
617997
- * Returns true if telemetry should be disabled.
618397
+ * Returns true if telemetry is enabled.
617998
618398
  *
617999
618399
  * Priority:
618000
618400
  * 1. FERN_TELEMETRY_DISABLED env var (any non-empty value)
@@ -618176,7 +618576,10 @@ var ApiDefinitionConverter = class {
618176
618576
  sourced
618177
618577
  });
618178
618578
  }
618179
- throw new Error(`Unknown spec type: ${JSON.stringify(spec)}`);
618579
+ throw new CliError({
618580
+ message: `Unknown spec type: ${JSON.stringify(spec)}`,
618581
+ code: CliError.Code.InternalError
618582
+ });
618180
618583
  }
618181
618584
  async convertOpenApiSpec({ absoluteFernYmlPath, spec, sourced }) {
618182
618585
  const result = {
@@ -619536,7 +619939,10 @@ var LegacyApiSpecAdapter = class {
619536
619939
  if (isOpenRpcSpec(spec)) {
619537
619940
  return this.adaptOpenRpcSpec(spec);
619538
619941
  }
619539
- throw new Error(`Unsupported spec type: ${JSON.stringify(spec)}`);
619942
+ throw new CliError({
619943
+ message: `Unsupported spec type: ${JSON.stringify(spec)}`,
619944
+ code: CliError.Code.InternalError
619945
+ });
619540
619946
  }
619541
619947
  convertAll(specs) {
619542
619948
  return specs.map((spec) => this.adapt(spec));
@@ -746685,7 +747091,10 @@ var LegacyFernWorkspaceAdapter = class {
746685
747091
  generatorsConfiguration: apiConfig != null ? this.buildGeneratorsConfiguration(apiConfig) : void 0
746686
747092
  });
746687
747093
  if (ossWorkspace == null) {
746688
- throw new Error("Internal error; failed to build API definitions");
747094
+ throw new CliError({
747095
+ message: "Internal error; failed to build API definitions",
747096
+ code: CliError.Code.InternalError
747097
+ });
746689
747098
  }
746690
747099
  return ossWorkspace.toFernWorkspace({ context: this.taskContext });
746691
747100
  }
@@ -747842,7 +748251,10 @@ function addSplitCommand(cli) {
747842
748251
  description: `Output format: '${OVERLAY_NAME}' (OpenAPI Overlay 1.0.0) or '${OVERRIDES_NAME}' (Fern deep-merge)`
747843
748252
  }).coerce("format", (value2) => {
747844
748253
  if (!ALL_FORMAT_NAMES.includes(value2)) {
747845
- throw new Error(`Invalid format '${value2}'. Expected one of: ${OVERLAY_NAME}, ${OVERRIDES_NAME}`);
748254
+ throw new CliError({
748255
+ message: `Invalid format '${value2}'. Expected one of: ${OVERLAY_NAME}, ${OVERRIDES_NAME}`,
748256
+ code: CliError.Code.ValidationError
748257
+ });
747846
748258
  }
747847
748259
  return value2;
747848
748260
  }));
@@ -788205,7 +788617,10 @@ var LambdaExampleEnhancer = class {
788205
788617
  this.context = context3;
788206
788618
  const lambdaOrigin = "https://ykq45y6fvnszd35iv5yuuatkze0rpwuz.lambda-url.us-east-1.on.aws";
788207
788619
  if (!lambdaOrigin) {
788208
- throw new Error("DEFAULT_FDR_LAMBDA_DOCS_ORIGIN environment variable is not set. AI example enhancement requires this to be configured.");
788620
+ throw new CliError({
788621
+ message: "DEFAULT_FDR_LAMBDA_DOCS_ORIGIN environment variable is not set. AI example enhancement requires this to be configured.",
788622
+ code: CliError.Code.EnvironmentError
788623
+ });
788209
788624
  }
788210
788625
  this.lambdaOrigin = lambdaOrigin;
788211
788626
  this.venusOrigin = "https://venus-dev2.buildwithfern.com";
@@ -788274,7 +788689,10 @@ var LambdaExampleEnhancer = class {
788274
788689
  });
788275
788690
  if (!response.ok) {
788276
788691
  const errorText = await response.text();
788277
- throw new Error(`Failed to fetch JWT from Venus: ${response.status} ${errorText || response.statusText}`);
788692
+ throw new CliError({
788693
+ message: `Failed to fetch JWT from Venus: ${response.status} ${errorText || response.statusText}`,
788694
+ code: CliError.Code.NetworkError
788695
+ });
788278
788696
  }
788279
788697
  const result = await response.json();
788280
788698
  this.context.logger.debug(`Successfully obtained JWT from Venus (expires at ${result.expiresAt})`);
@@ -788336,7 +788754,10 @@ var LambdaExampleEnhancer = class {
788336
788754
  });
788337
788755
  if (!response.ok) {
788338
788756
  const errorText = await response.text();
788339
- throw new Error(`Lambda returned ${response.status}: ${errorText || response.statusText}`);
788757
+ throw new CliError({
788758
+ message: `Lambda returned ${response.status}: ${errorText || response.statusText}`,
788759
+ code: CliError.Code.NetworkError
788760
+ });
788340
788761
  }
788341
788762
  const result = await response.json();
788342
788763
  return {
@@ -789849,7 +790270,10 @@ function convertTypeShape(irType) {
789849
790270
  extraProperties: void 0
789850
790271
  }),
789851
790272
  _other: () => {
789852
- throw new Error("Unknown SingleUnionTypeProperties: " + variant.shape.propertiesType);
790273
+ throw new CliError({
790274
+ message: "Unknown SingleUnionTypeProperties: " + variant.shape.propertiesType,
790275
+ code: CliError.Code.InternalError
790276
+ });
789853
790277
  }
789854
790278
  })
789855
790279
  };
@@ -789874,7 +790298,7 @@ function convertTypeShape(irType) {
789874
790298
  };
789875
790299
  },
789876
790300
  _other: () => {
789877
- throw new Error("Unknown Type shape: " + irType.type);
790301
+ throw new CliError({ message: "Unknown Type shape: " + irType.type, code: CliError.Code.InternalError });
789878
790302
  }
789879
790303
  });
789880
790304
  }
@@ -789941,12 +790365,18 @@ function convertTypeReference3(irTypeReference) {
789941
790365
  };
789942
790366
  },
789943
790367
  _other: () => {
789944
- throw new Error("Unknown literal type: " + literal3.type);
790368
+ throw new CliError({
790369
+ message: "Unknown literal type: " + literal3.type,
790370
+ code: CliError.Code.InternalError
790371
+ });
789945
790372
  }
789946
790373
  });
789947
790374
  },
789948
790375
  _other: () => {
789949
- throw new Error("Unknown container reference: " + container.type);
790376
+ throw new CliError({
790377
+ message: "Unknown container reference: " + container.type,
790378
+ code: CliError.Code.InternalError
790379
+ });
789950
790380
  }
789951
790381
  });
789952
790382
  },
@@ -790026,7 +790456,10 @@ function convertTypeReference3(irTypeReference) {
790026
790456
  };
790027
790457
  },
790028
790458
  _other: () => {
790029
- throw new Error("Unknown primitive: " + primitive.v1);
790459
+ throw new CliError({
790460
+ message: "Unknown primitive: " + primitive.v1,
790461
+ code: CliError.Code.InternalError
790462
+ });
790030
790463
  }
790031
790464
  })
790032
790465
  };
@@ -790037,7 +790470,10 @@ function convertTypeReference3(irTypeReference) {
790037
790470
  };
790038
790471
  },
790039
790472
  _other: () => {
790040
- throw new Error("Unknown Type reference: " + irTypeReference.type);
790473
+ throw new CliError({
790474
+ message: "Unknown Type reference: " + irTypeReference.type,
790475
+ code: CliError.Code.InternalError
790476
+ });
790041
790477
  }
790042
790478
  });
790043
790479
  }
@@ -790501,7 +790937,10 @@ function convertIrEnvironments({ environmentsConfig, endpoint: endpoint3 }) {
790501
790937
  return environmentsConfigValue.environments.map((singleBaseUrlEnvironment) => {
790502
790938
  const endpointBaseUrl = singleBaseUrlEnvironment.urls[baseUrlId];
790503
790939
  if (endpointBaseUrl == null) {
790504
- throw new Error(`Encountered undefined server name "${baseUrlId}" at endpoint ${endpoint3.method.toUpperCase()} ${endpoint3.path}. Expected environment ${singleBaseUrlEnvironment.id} to contain url for ${baseUrlId}`);
790940
+ throw new CliError({
790941
+ message: `Encountered undefined server name "${baseUrlId}" at endpoint ${endpoint3.method.toUpperCase()} ${endpoint3.path}. Expected environment ${singleBaseUrlEnvironment.id} to contain url for ${baseUrlId}`,
790942
+ code: CliError.Code.IrConversionError
790943
+ });
790505
790944
  }
790506
790945
  return {
790507
790946
  id: FdrAPI_exports.EnvironmentId(baseUrlId),
@@ -790513,12 +790952,18 @@ function convertIrEnvironments({ environmentsConfig, endpoint: endpoint3 }) {
790513
790952
  return environments2.filter((environment2, index3, self2) => index3 === self2.findIndex((t3) => t3.id === environment2.id && t3.baseUrl === environment2.baseUrl));
790514
790953
  }
790515
790954
  if (endpointBaseUrlId == null) {
790516
- throw new Error(`Expected endpoint ${getOriginalName(endpoint3.name)} to have base url.`);
790955
+ throw new CliError({
790956
+ message: `Expected endpoint ${getOriginalName(endpoint3.name)} to have base url.`,
790957
+ code: CliError.Code.IrConversionError
790958
+ });
790517
790959
  }
790518
790960
  return environmentsConfigValue.environments.map((singleBaseUrlEnvironment) => {
790519
790961
  const endpointBaseUrl = singleBaseUrlEnvironment.urls[endpointBaseUrlId];
790520
790962
  if (endpointBaseUrl == null) {
790521
- throw new Error(`Encountered undefined server name "${endpointBaseUrlId}" at endpoint ${endpoint3.method.toUpperCase()} ${endpoint3.path.head}. Expected environment ${singleBaseUrlEnvironment.id} to contain url for ${endpointBaseUrlId}`);
790963
+ throw new CliError({
790964
+ message: `Encountered undefined server name "${endpointBaseUrlId}" at endpoint ${endpoint3.method.toUpperCase()} ${endpoint3.path.head}. Expected environment ${singleBaseUrlEnvironment.id} to contain url for ${endpointBaseUrlId}`,
790965
+ code: CliError.Code.IrConversionError
790966
+ });
790522
790967
  }
790523
790968
  return {
790524
790969
  id: FdrAPI_exports.EnvironmentId(singleBaseUrlEnvironment.id),
@@ -790544,12 +790989,18 @@ function convertIrWebSocketEnvironments({ environmentsConfig, channel: channel3
790544
790989
  });
790545
790990
  case "multipleBaseUrls":
790546
790991
  if (channelBaseUrlId == null) {
790547
- throw new Error(`Expected channel ${getOriginalName(channel3.name)} to have base url.`);
790992
+ throw new CliError({
790993
+ message: `Expected channel ${getOriginalName(channel3.name)} to have base url.`,
790994
+ code: CliError.Code.IrConversionError
790995
+ });
790548
790996
  }
790549
790997
  return environmentsConfigValue.environments.map((singleBaseUrlEnvironment) => {
790550
790998
  const channelBaseUrl = singleBaseUrlEnvironment.urls[channelBaseUrlId];
790551
790999
  if (channelBaseUrl == null) {
790552
- throw new Error(`Encountered undefined server name ${channelBaseUrl} at channel ${getOriginalName(channel3.name)} ${channel3.path.head}. Expected environment ${singleBaseUrlEnvironment.id} to contain url for ${channelBaseUrlId}`);
791000
+ throw new CliError({
791001
+ message: `Encountered undefined server name ${channelBaseUrl} at channel ${getOriginalName(channel3.name)} ${channel3.path.head}. Expected environment ${singleBaseUrlEnvironment.id} to contain url for ${channelBaseUrlId}`,
791002
+ code: CliError.Code.IrConversionError
791003
+ });
790553
791004
  }
790554
791005
  return {
790555
791006
  id: FdrAPI_exports.EnvironmentId(singleBaseUrlEnvironment.id),
@@ -790573,7 +791024,7 @@ function convertHttpMethod2(method8) {
790573
791024
  delete: () => FdrAPI_exports.HttpMethod.Delete,
790574
791025
  head: () => FdrAPI_exports.HttpMethod.Head,
790575
791026
  _other: () => {
790576
- throw new Error("Unknown http method: " + method8);
791027
+ throw new CliError({ message: "Unknown http method: " + method8, code: CliError.Code.InternalError });
790577
791028
  }
790578
791029
  });
790579
791030
  }
@@ -790689,7 +791140,10 @@ function convertRequestBody3(irRequest) {
790689
791140
  contentType: bytes.contentType
790690
791141
  }),
790691
791142
  _other: () => {
790692
- throw new Error("Unknown HttpRequestBody: " + irRequest.type);
791143
+ throw new CliError({
791144
+ message: "Unknown HttpRequestBody: " + irRequest.type,
791145
+ code: CliError.Code.InternalError
791146
+ });
790693
791147
  }
790694
791148
  });
790695
791149
  return requestBodyShape != null ? { type: requestBodyShape, description: irRequest.docs } : void 0;
@@ -790743,7 +791197,10 @@ function convertResponse2(irResponse) {
790743
791197
  return void 0;
790744
791198
  },
790745
791199
  _other: () => {
790746
- throw new Error("Unknown HttpResponse: " + irResponse.body);
791200
+ throw new CliError({
791201
+ message: "Unknown HttpResponse: " + irResponse.body,
791202
+ code: CliError.Code.InternalError
791203
+ });
790747
791204
  }
790748
791205
  });
790749
791206
  }
@@ -790983,7 +791440,10 @@ function convertV2HttpEndpointExample({ shouldUseExampleName, exampleName, examp
790983
791440
  return void 0;
790984
791441
  },
790985
791442
  _other: () => {
790986
- throw new Error("Unknown ExampleResponseBody: " + example.response?.body?.type);
791443
+ throw new CliError({
791444
+ message: "Unknown ExampleResponseBody: " + example.response?.body?.type,
791445
+ code: CliError.Code.InternalError
791446
+ });
790987
791447
  }
790988
791448
  }) : void 0,
790989
791449
  codeSamples: example.codeSamples?.map((codeSample) => ({
@@ -791109,18 +791569,27 @@ function convertHttpEndpointExample({ userSpecifiedExample, autogeneratedExample
791109
791569
  stream: (stream5) => stream5.length > 0 ? 200 : 204,
791110
791570
  sse: (stream5) => stream5.length > 0 ? 200 : 204,
791111
791571
  _other: () => {
791112
- throw new Error("Unknown ExampleResponseBody: " + ok3.type);
791572
+ throw new CliError({
791573
+ message: "Unknown ExampleResponseBody: " + ok3.type,
791574
+ code: CliError.Code.InternalError
791575
+ });
791113
791576
  }
791114
791577
  }),
791115
791578
  error: ({ error: errorName }) => {
791116
791579
  const error50 = ir10.errors[errorName.errorId];
791117
791580
  if (error50 == null) {
791118
- throw new Error("Cannot find error " + errorName.errorId);
791581
+ throw new CliError({
791582
+ message: "Cannot find error " + errorName.errorId,
791583
+ code: CliError.Code.ResolutionError
791584
+ });
791119
791585
  }
791120
791586
  return error50.statusCode;
791121
791587
  },
791122
791588
  _other: () => {
791123
- throw new Error("Unknown ExampleResponse: " + example.response.type);
791589
+ throw new CliError({
791590
+ message: "Unknown ExampleResponse: " + example.response.type,
791591
+ code: CliError.Code.InternalError
791592
+ });
791124
791593
  }
791125
791594
  }),
791126
791595
  responseBody: example.response._visit({
@@ -791142,12 +791611,18 @@ function convertHttpEndpointExample({ userSpecifiedExample, autogeneratedExample
791142
791611
  value: sse.map(({ event, data: data2 }) => ({ event, data: data2.jsonExample }))
791143
791612
  }),
791144
791613
  _other: () => {
791145
- throw new Error("Unknown ExampleResponseBody: " + ok3.type);
791614
+ throw new CliError({
791615
+ message: "Unknown ExampleResponseBody: " + ok3.type,
791616
+ code: CliError.Code.InternalError
791617
+ });
791146
791618
  }
791147
791619
  }),
791148
791620
  error: (error50) => error50.body != null ? { type: "json", value: error50.body.jsonExample } : void 0,
791149
791621
  _other: () => {
791150
- throw new Error("Unknown ExampleResponse: " + example.response.type);
791622
+ throw new CliError({
791623
+ message: "Unknown ExampleResponse: " + example.response.type,
791624
+ code: CliError.Code.InternalError
791625
+ });
791151
791626
  }
791152
791627
  }),
791153
791628
  // irExample.response.body != null ? { type: "json", value: irExample.response.body.jsonExample } : undefined,
@@ -791440,7 +791915,9 @@ async function registerApi({ organization, workspace, context: context3, token,
791440
791915
  context3.logger.debug(`Registered API Definition ${response.apiDefinitionId}`);
791441
791916
  return { id: response.apiDefinitionId, ir: ir10 };
791442
791917
  } catch (error50) {
791443
- return context3.failAndThrow("Failed to register API", error50);
791918
+ return context3.failAndThrow("Failed to register API", error50, {
791919
+ code: CliError.Code.NetworkError
791920
+ });
791444
791921
  }
791445
791922
  }
791446
791923
 
@@ -827894,7 +828371,7 @@ var DocsWorkspaceValidator = class {
827894
828371
  const startTime = performance.now();
827895
828372
  if (workspace.config.settings?.substituteEnvVars) {
827896
828373
  workspace.config = replaceEnvVariables(workspace.config, {
827897
- onError: (error50) => this.taskContext.failAndThrow(error50)
828374
+ onError: (error50) => this.taskContext.failAndThrow(error50, void 0, { code: CliError.Code.ConfigError })
827898
828375
  });
827899
828376
  }
827900
828377
  const violations = await validateDocsWorkspace(workspace, this.taskContext, apiWorkspaces, ossWorkspaces, false, excludeRules);
@@ -831728,7 +832205,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
831728
832205
  var LOGS_FOLDER_NAME = "logs";
831729
832206
  var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
831730
832207
  function getCliSource() {
831731
- const version7 = "4.81.1";
832208
+ const version7 = "4.82.0-1-g000d7384e60";
831732
832209
  return `cli@${version7}`;
831733
832210
  }
831734
832211
  var DebugLogger = class {
@@ -841126,7 +841603,10 @@ async function retryWithRateLimit({ fn: fn10, retryRateLimited, logger: logger4,
841126
841603
  }
841127
841604
  }
841128
841605
  }
841129
- throw new Error("Exceeded maximum retries for 429 Too Many Requests.");
841606
+ throw new CliError({
841607
+ message: "Exceeded maximum retries for 429 Too Many Requests.",
841608
+ code: CliError.Code.InternalError
841609
+ });
841130
841610
  }
841131
841611
 
841132
841612
  // ../generation/remote-generation/remote-workspace-runner/lib/createAndStartJob.js
@@ -841139,7 +841619,9 @@ async function createAndStartJob({ projectConfig, workspace, organization, inter
841139
841619
  try {
841140
841620
  fernignoreContents = await (0, import_promises86.readFile)(fernignorePath, "utf-8");
841141
841621
  } catch (error50) {
841142
- context3.failAndThrow(`Failed to read fernignore file at ${fernignorePath}: ${error50}`);
841622
+ context3.failAndThrow(`Failed to read fernignore file at ${fernignorePath}: ${error50}`, void 0, {
841623
+ code: CliError.Code.ConfigError
841624
+ });
841143
841625
  }
841144
841626
  }
841145
841627
  const job = await retryWithRateLimit({
@@ -841162,7 +841644,7 @@ async function createAndStartJob({ projectConfig, workspace, organization, inter
841162
841644
  }),
841163
841645
  retryRateLimited,
841164
841646
  logger: context3.logger,
841165
- onRateLimitedWithoutRetry: () => context3.failAndThrow("Received 429 Too Many Requests. Re-run with --retry-rate-limited to automatically retry.")
841647
+ onRateLimitedWithoutRetry: () => context3.failAndThrow("Received 429 Too Many Requests. Re-run with --retry-rate-limited to automatically retry.", void 0, { code: CliError.Code.NetworkError })
841166
841648
  });
841167
841649
  await startJob({ intermediateRepresentation, job, context: context3, generatorInvocation, irVersionOverride });
841168
841650
  return job;
@@ -841212,33 +841694,35 @@ async function createJob({ projectConfig, workspace, organization, generatorInvo
841212
841694
  }
841213
841695
  return convertCreateJobError(rawError)._visit({
841214
841696
  illegalApiNameError: () => {
841215
- return context3.failAndThrow("API name is invalid: " + workspace.definition.rootApiFile.contents.name);
841697
+ return context3.failAndThrow("API name is invalid: " + workspace.definition.rootApiFile.contents.name, void 0, { code: CliError.Code.ConfigError });
841216
841698
  },
841217
841699
  illegalApiVersionError: () => {
841218
- return context3.failAndThrow("API version is invalid: " + version7);
841700
+ return context3.failAndThrow("API version is invalid: " + version7, void 0, {
841701
+ code: CliError.Code.ConfigError
841702
+ });
841219
841703
  },
841220
841704
  cannotPublishToNpmScope: ({ validScope, invalidScope }) => {
841221
- return context3.failAndThrow(`You do not have permission to publish to ${invalidScope} (expected ${validScope})`);
841705
+ return context3.failAndThrow(`You do not have permission to publish to ${invalidScope} (expected ${validScope})`, void 0, { code: CliError.Code.AuthError });
841222
841706
  },
841223
841707
  cannotPublishToMavenGroup: ({ validGroup, invalidGroup }) => {
841224
- return context3.failAndThrow(`You do not have permission to publish to ${invalidGroup} (expected ${validGroup})`);
841708
+ return context3.failAndThrow(`You do not have permission to publish to ${invalidGroup} (expected ${validGroup})`, void 0, { code: CliError.Code.AuthError });
841225
841709
  },
841226
841710
  cannotPublishPypiPackage: ({ validPrefix, invalidPackageName }) => {
841227
- return context3.failAndThrow(`You do not have permission to publish to ${invalidPackageName} (expected ${validPrefix})`);
841711
+ return context3.failAndThrow(`You do not have permission to publish to ${invalidPackageName} (expected ${validPrefix})`, void 0, { code: CliError.Code.AuthError });
841228
841712
  },
841229
841713
  generatorsDoNotExistError: (value2) => {
841230
- return context3.failAndThrow("Generators do not exist: " + value2.nonExistentGenerators.map((generator) => `${generator.id}@${generator.version}`).join(", "));
841714
+ return context3.failAndThrow("Generators do not exist: " + value2.nonExistentGenerators.map((generator) => `${generator.id}@${generator.version}`).join(", "), void 0, { code: CliError.Code.ConfigError });
841231
841715
  },
841232
841716
  insufficientPermissions: () => {
841233
841717
  return context3.failAndThrow(`You do not have permission to run this generator for organization '${organization}'. Please run 'fern login' to ensure you are logged in with the correct account.
841234
841718
 
841235
- Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`);
841719
+ Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`, void 0, { code: CliError.Code.AuthError });
841236
841720
  },
841237
841721
  orgNotConfiguredForWhitelabel: () => {
841238
- return context3.failAndThrow("Your org is not configured for white-labeling. Please reach out to support@buildwithfern.com.");
841722
+ return context3.failAndThrow("Your org is not configured for white-labeling. Please reach out to support@buildwithfern.com.", void 0, { code: CliError.Code.AuthError });
841239
841723
  },
841240
841724
  branchDoesNotExist: (value2) => {
841241
- return context3.failAndThrow(`Branch ${value2.branch} does not exist in repository ${value2.repositoryOwner}/${value2.repositoryName}`);
841725
+ return context3.failAndThrow(`Branch ${value2.branch} does not exist in repository ${value2.repositoryOwner}/${value2.repositoryName}`, void 0, { code: CliError.Code.ConfigError });
841242
841726
  },
841243
841727
  rateLimitExceeded: () => {
841244
841728
  throw new TooManyRequestsError();
@@ -841247,9 +841731,9 @@ Please ensure you have membership at https://dashboard.buildwithfern.com, and as
841247
841731
  context3.logger.debug(`Failed to create job: ${JSON.stringify(content5)}`);
841248
841732
  const errorMessage = extractErrorMessage2(content5);
841249
841733
  if (errorMessage != null) {
841250
- return context3.failAndThrow(errorMessage);
841734
+ return context3.failAndThrow(errorMessage, void 0, { code: CliError.Code.NetworkError });
841251
841735
  }
841252
- return context3.failAndThrow("Failed to create job. Please try again or contact support@buildwithfern.com for assistance.");
841736
+ return context3.failAndThrow("Failed to create job. Please try again or contact support@buildwithfern.com for assistance.", void 0, { code: CliError.Code.NetworkError });
841253
841737
  }
841254
841738
  });
841255
841739
  }
@@ -841294,7 +841778,7 @@ async function startJob({ intermediateRepresentation, generatorInvocation, job,
841294
841778
  } catch (error50) {
841295
841779
  const errorBody = error50 instanceof AxiosError2 ? error50.response?.data : error50;
841296
841780
  context3.logger.debug(`POST ${url3} failed with ${JSON.stringify(error50)}`);
841297
- context3.failAndThrow("Failed to start job", errorBody);
841781
+ context3.failAndThrow("Failed to start job", errorBody, { code: CliError.Code.NetworkError });
841298
841782
  }
841299
841783
  }
841300
841784
  function extractErrorMessage2(error50) {
@@ -841361,7 +841845,9 @@ function pollJobAndReportStatus({ job, taskId, taskHandler, context: context3 })
841361
841845
  if (taskStatus == null) {
841362
841846
  numConsecutiveFailed++;
841363
841847
  if (numConsecutiveFailed === MAX_UNSUCCESSFUL_ATTEMPTS) {
841364
- context3.failAndThrow(`Failed to get job status after ${numConsecutiveFailed} attempts.`);
841848
+ context3.failAndThrow(`Failed to get job status after ${numConsecutiveFailed} attempts.`, void 0, {
841849
+ code: CliError.Code.NetworkError
841850
+ });
841365
841851
  }
841366
841852
  setTimeout(pollForStatus, 2e3 + 1e3 * numConsecutiveFailed);
841367
841853
  } else {
@@ -841418,7 +841904,9 @@ var RemoteTaskHandler = class {
841418
841904
  }
841419
841905
  async processUpdate(remoteTask2) {
841420
841906
  if (remoteTask2 == null) {
841421
- this.context.failAndThrow("Task is missing on job status");
841907
+ this.context.failAndThrow("Task is missing on job status", void 0, {
841908
+ code: CliError.Code.InternalError
841909
+ });
841422
841910
  }
841423
841911
  const coordinates = remoteTask2.packages.map((p9) => {
841424
841912
  return p9.coordinate._visit({
@@ -841469,7 +841957,7 @@ var RemoteTaskHandler = class {
841469
841957
  if (s3PreSignedReadUrl != null) {
841470
841958
  logS3Url(s3PreSignedReadUrl);
841471
841959
  }
841472
- this.context.failAndThrow(message);
841960
+ this.context.failAndThrow(message, void 0, { code: CliError.Code.ContainerError });
841473
841961
  },
841474
841962
  finished: async (finishedStatus) => {
841475
841963
  if (finishedStatus.s3PreSignedReadUrlV2 != null) {
@@ -841546,7 +842034,7 @@ async function downloadFilesForTask({ s3PreSignedReadUrl, absolutePathToLocalOut
841546
842034
  }
841547
842035
  context3.logger.info(source_default.green(`Downloaded to ${absolutePathToLocalOutput}`));
841548
842036
  } catch (e5) {
841549
- context3.failAndThrow("Failed to download files", e5);
842037
+ context3.failAndThrow("Failed to download files", e5, { code: CliError.Code.NetworkError });
841550
842038
  }
841551
842039
  }
841552
842040
  async function downloadZipForTask({ s3PreSignedReadUrl, absolutePathToLocalOutput }) {
@@ -841723,7 +842211,7 @@ var SourceUploader = class {
841723
842211
  });
841724
842212
  await uploadCommand.cleanup();
841725
842213
  if (!response.ok) {
841726
- this.context.failAndThrow(`Failed to upload source file: ${source2.absoluteFilePath}. Status: ${response.status}, ${response.statusText}`);
842214
+ this.context.failAndThrow(`Failed to upload source file: ${source2.absoluteFilePath}. Status: ${response.status}, ${response.statusText}`, void 0, { code: CliError.Code.NetworkError });
841727
842215
  }
841728
842216
  }
841729
842217
  async getUploadCommand(source2) {
@@ -841778,7 +842266,7 @@ var SourceUploader = class {
841778
842266
  getSourceOrThrow(id) {
841779
842267
  const source2 = this.sources[id];
841780
842268
  if (source2 == null) {
841781
- this.context.failAndThrow(`Internal error; server responded with source id "${id}" which does not exist in the workspace.`);
842269
+ this.context.failAndThrow(`Internal error; server responded with source id "${id}" which does not exist in the workspace.`, void 0, { code: CliError.Code.InternalError });
841782
842270
  }
841783
842271
  return source2;
841784
842272
  }
@@ -841794,7 +842282,9 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
841794
842282
  const substituteEnvVars = (stringOrObject) => replaceEnvVariables(stringOrObject, {
841795
842283
  onError: (e5) => {
841796
842284
  if (!isPreview && requireEnvVars) {
841797
- interactiveTaskContext.failAndThrow(e5);
842285
+ interactiveTaskContext.failAndThrow(void 0, e5, {
842286
+ code: CliError.Code.EnvironmentError
842287
+ });
841798
842288
  }
841799
842289
  }
841800
842290
  }, { substituteAsEmpty: isPreview });
@@ -841894,7 +842384,9 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
841894
842384
  }
841895
842385
  const sourceUploader = new SourceUploader(interactiveTaskContext, sources);
841896
842386
  if (sourceUploads == null && sourceUploader.sourceTypes.has("protobuf")) {
841897
- interactiveTaskContext.failAndThrow("Did not successfully upload Protobuf source files.");
842387
+ interactiveTaskContext.failAndThrow("Did not successfully upload Protobuf source files.", void 0, {
842388
+ code: CliError.Code.NetworkError
842389
+ });
841898
842390
  }
841899
842391
  if (sourceUploads != null) {
841900
842392
  interactiveTaskContext.logger.debug("Uploading source files ...");
@@ -841905,15 +842397,21 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
841905
842397
  if (dynamicIrOnly) {
841906
842398
  interactiveTaskContext.logger.info("Dynamic IR only mode: skipping SDK generation and uploading dynamic IR only");
841907
842399
  if (version7 == null) {
841908
- interactiveTaskContext.failAndThrow("Version is required for dynamic IR only mode");
842400
+ interactiveTaskContext.failAndThrow("Version is required for dynamic IR only mode", void 0, {
842401
+ code: CliError.Code.ConfigError
842402
+ });
841909
842403
  return void 0;
841910
842404
  }
841911
842405
  if (generatorInvocation.language == null) {
841912
- interactiveTaskContext.failAndThrow("Language is required for dynamic IR only mode");
842406
+ interactiveTaskContext.failAndThrow("Language is required for dynamic IR only mode", void 0, {
842407
+ code: CliError.Code.ConfigError
842408
+ });
841913
842409
  return void 0;
841914
842410
  }
841915
842411
  if (packageName == null) {
841916
- interactiveTaskContext.failAndThrow("Package name is required for dynamic IR only mode");
842412
+ interactiveTaskContext.failAndThrow("Package name is required for dynamic IR only mode", void 0, {
842413
+ code: CliError.Code.ConfigError
842414
+ });
841917
842415
  return void 0;
841918
842416
  }
841919
842417
  try {
@@ -841929,7 +842427,7 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
841929
842427
  context: interactiveTaskContext
841930
842428
  });
841931
842429
  } catch (error50) {
841932
- interactiveTaskContext.failAndThrow(`Failed to upload dynamic IR: ${extractErrorMessage(error50)}`);
842430
+ interactiveTaskContext.failAndThrow(`Failed to upload dynamic IR: ${extractErrorMessage(error50)}`, void 0, { code: CliError.Code.NetworkError });
841933
842431
  }
841934
842432
  return {
841935
842433
  createdSnippets: false,
@@ -841965,7 +842463,9 @@ async function runRemoteGenerationForGenerator({ projectConfig, organization, wo
841965
842463
  interactiveTaskContext.logger.debug(`Job ID: ${job.jobId}`);
841966
842464
  const taskId = job.taskIds[0];
841967
842465
  if (taskId == null) {
841968
- interactiveTaskContext.failAndThrow("Did not receive a task ID.");
842466
+ interactiveTaskContext.failAndThrow("Did not receive a task ID.", void 0, {
842467
+ code: CliError.Code.NetworkError
842468
+ });
841969
842469
  return void 0;
841970
842470
  }
841971
842471
  interactiveTaskContext.logger.debug(`Task ID: ${taskId}`);
@@ -842131,7 +842631,7 @@ async function runRemoteGenerationForAPIWorkspace({ projectConfig, organization,
842131
842631
  onSnippetsProduced: (invocation) => snippetsProducedBy.push(invocation)
842132
842632
  }))));
842133
842633
  if (automation == null && results.some((didSucceed) => !didSucceed)) {
842134
- context3.failAndThrow();
842634
+ throw new TaskAbortSignal();
842135
842635
  }
842136
842636
  return {
842137
842637
  snippetsProducedBy
@@ -842570,9 +843070,9 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain3
842570
843070
  context3.logger.error(`FDR registerApiDefinition failed. Error details:
842571
843071
  ${JSON.stringify(errorDetails, void 0, 2)}`);
842572
843072
  if (apiName != null) {
842573
- return context3.failAndThrow(`Failed to publish docs because API definition (${apiName}) could not be uploaded. Please contact support@buildwithfern.com`, errorDetails);
843073
+ return context3.failAndThrow(`Failed to publish docs because API definition (${apiName}) could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
842574
843074
  } else {
842575
- return context3.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com`, errorDetails);
843075
+ return context3.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com`, errorDetails, { code: CliError.Code.NetworkError });
842576
843076
  }
842577
843077
  }
842578
843078
  context3.logger.debug(`Registered API Definition ${apiName}: ${response.apiDefinitionId}`);
@@ -842599,7 +843099,7 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
842599
843099
  if (docsWorkspace.config.settings?.substituteEnvVars) {
842600
843100
  context3.logger.debug("Applying environment variable substitution to docs definition...");
842601
843101
  const { jsFiles, ...docsWithoutJsFiles } = docsDefinition;
842602
- const substitutedDocs = replaceEnvVariables(docsWithoutJsFiles, { onError: (e5) => context3.failAndThrow(e5) }, { substituteAsEmpty: false });
843102
+ const substitutedDocs = replaceEnvVariables(docsWithoutJsFiles, { onError: (e5) => context3.failAndThrow(void 0, e5, { code: CliError.Code.EnvironmentError }) }, { substituteAsEmpty: false });
842603
843103
  docsDefinition = { ...substitutedDocs, jsFiles };
842604
843104
  }
842605
843105
  const pageCount = Object.keys(docsDefinition.pages).length;
@@ -842609,7 +843109,9 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
842609
843109
  context3.logger.debug(`Memory after resolve: RSS=${(resolveMemory.rss / 1024 / 1024).toFixed(2)}MB, Heap=${(resolveMemory.heapUsed / 1024 / 1024).toFixed(2)}MB`);
842610
843110
  if (docsRegistrationId == null) {
842611
843111
  doUnlock();
842612
- return context3.failAndThrow("Failed to publish docs.", "Docs registration ID is missing.");
843112
+ return context3.failAndThrow("Failed to publish docs.", "Docs registration ID is missing.", {
843113
+ code: CliError.Code.InternalError
843114
+ });
842613
843115
  }
842614
843116
  context3.logger.info("Publishing docs to FDR...");
842615
843117
  const publishStart = performance.now();
@@ -842621,7 +843123,9 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
842621
843123
  ...isBasepathAware && !preview && { basepathAware: true }
842622
843124
  });
842623
843125
  } catch (error50) {
842624
- return context3.failAndThrow("Failed to publish docs to " + domain3, error50);
843126
+ return context3.failAndThrow("Failed to publish docs to " + domain3, error50, {
843127
+ code: CliError.Code.NetworkError
843128
+ });
842625
843129
  }
842626
843130
  const publishTime = performance.now() - publishStart;
842627
843131
  context3.logger.debug(`Docs published to FDR in ${publishTime.toFixed(0)}ms`);
@@ -842681,7 +843185,9 @@ async function uploadFiles(filesToUpload, docsWorkspacePath, context3, batchSize
842681
843185
  }
842682
843186
  });
842683
843187
  } catch (e5) {
842684
- context3.failAndThrow(`Failed to upload ${absoluteFilePath}`, e5);
843188
+ context3.failAndThrow(`Failed to upload ${absoluteFilePath}`, e5, {
843189
+ code: CliError.Code.NetworkError
843190
+ });
842685
843191
  }
842686
843192
  }));
842687
843193
  const endTime2 = Date.now();
@@ -842721,24 +843227,26 @@ ${JSON.stringify(errorDetails, void 0, 2)}`);
842721
843227
  }
842722
843228
  const authErrorMessage = getAuthenticationErrorMessage(error50, organization, domain3);
842723
843229
  if (authErrorMessage != null) {
842724
- return context3.failAndThrow(authErrorMessage);
843230
+ return context3.failAndThrow(authErrorMessage, void 0, { code: CliError.Code.AuthError });
842725
843231
  }
842726
843232
  const errorType = errorObj?.error;
842727
843233
  switch (errorType) {
842728
843234
  case "InvalidCustomDomainError":
842729
- return context3.failAndThrow(`Your docs domain should end with ${"docs.dev.buildwithfern.com"}`);
843235
+ return context3.failAndThrow(`Your docs domain should end with ${"docs.dev.buildwithfern.com"}`, void 0, { code: CliError.Code.ConfigError });
842730
843236
  case "InvalidDomainError":
842731
- return context3.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");
843237
+ return context3.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)", void 0, { code: CliError.Code.ConfigError });
842732
843238
  case "UnauthorizedError":
842733
- return context3.failAndThrow(buildAuthFailureMessage(domain3, organization, errorContent));
843239
+ return context3.failAndThrow(buildAuthFailureMessage(domain3, organization, errorContent), void 0, {
843240
+ code: CliError.Code.AuthError
843241
+ });
842734
843242
  case "UserNotInOrgError":
842735
843243
  return context3.failAndThrow(`You do not belong to organization '${organization}'. Please run 'fern login' to ensure you are logged in with the correct account.
842736
843244
 
842737
- Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`);
843245
+ Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`, void 0, { code: CliError.Code.AuthError });
842738
843246
  case "UnavailableError":
842739
- return context3.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");
843247
+ return context3.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.", void 0, { code: CliError.Code.NetworkError });
842740
843248
  default:
842741
- return context3.failAndThrow("Failed to publish docs.", error50);
843249
+ return context3.failAndThrow("Failed to publish docs.", error50, { code: CliError.Code.NetworkError });
842742
843250
  }
842743
843251
  }
842744
843252
  function getAuthenticationErrorMessage(error50, organization, domain3) {
@@ -843186,21 +843694,25 @@ async function runRemoteGenerationForDocsWorkspace({ organization, apiWorkspaces
843186
843694
  docsWorkspace.config = replaceEnvVariables(
843187
843695
  docsWorkspace.config,
843188
843696
  // Wrap in a closure for correct binding of `this` downstream
843189
- { onError: (e5) => context3.failAndThrow(e5) },
843697
+ { onError: (e5) => context3.failAndThrow(void 0, e5, { code: CliError.Code.EnvironmentError }) },
843190
843698
  { substituteAsEmpty: shouldSubstituteAsEmpty }
843191
843699
  );
843192
843700
  const instances2 = docsWorkspace.config.instances;
843193
843701
  if (instances2.length === 0) {
843194
- context3.failAndThrow("No instances specified in docs.yml! Cannot register docs.");
843702
+ context3.failAndThrow("No instances specified in docs.yml! Cannot register docs.", void 0, {
843703
+ code: CliError.Code.ConfigError
843704
+ });
843195
843705
  return;
843196
843706
  }
843197
843707
  if (instances2.length > 1 && instanceUrl == null) {
843198
- context3.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${instances2[0]?.url})`);
843708
+ context3.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${instances2[0]?.url})`, void 0, { code: CliError.Code.ConfigError });
843199
843709
  return;
843200
843710
  }
843201
843711
  const maybeInstance = instances2.find((instance) => instance.url === instanceUrl) ?? instances2[0];
843202
843712
  if (maybeInstance == null) {
843203
- context3.failAndThrow(`No docs instance with url ${instanceUrl}. Failed to register.`);
843713
+ context3.failAndThrow(`No docs instance with url ${instanceUrl}. Failed to register.`, void 0, {
843714
+ code: CliError.Code.ConfigError
843715
+ });
843204
843716
  return;
843205
843717
  }
843206
843718
  const customDomains = [];
@@ -843245,7 +843757,7 @@ async function runRemoteGenerationForDocsWorkspace({ organization, apiWorkspaces
843245
843757
  } catch (error50) {
843246
843758
  if (!(error50 instanceof DocsPublishConflictError) || attempt >= PUBLISH_CONFLICT_RETRY_DELAYS_MS.length) {
843247
843759
  if (error50 instanceof DocsPublishConflictError) {
843248
- return context3.failAndThrow("Another docs publish is currently in progress. Please try again once the other publish is complete.");
843760
+ return context3.failAndThrow("Another docs publish is currently in progress. Please try again once the other publish is complete.", void 0, { code: CliError.Code.NetworkError });
843249
843761
  }
843250
843762
  throw error50;
843251
843763
  }
@@ -843295,7 +843807,7 @@ var LegacyDocsPublisher = class {
843295
843807
  previewId,
843296
843808
  disableTemplates: void 0,
843297
843809
  skipUpload,
843298
- cliVersion: "4.81.1"
843810
+ cliVersion: "4.82.0-1-g000d7384e60"
843299
843811
  });
843300
843812
  if (taskContext.getResult() === TaskResult.Failure) {
843301
843813
  return { success: false };
@@ -843770,7 +844282,10 @@ var DocsTask = class {
843770
844282
  getTask() {
843771
844283
  const task = this.taskGroup.getTask(this.id);
843772
844284
  if (task == null) {
843773
- throw new Error(`Internal error; task '${this.id}' does not exist`);
844285
+ throw new CliError({
844286
+ message: `Internal error; task '${this.id}' does not exist`,
844287
+ code: CliError.Code.InternalError
844288
+ });
843774
844289
  }
843775
844290
  return task;
843776
844291
  }
@@ -845042,7 +845557,10 @@ var Wizard = class {
845042
845557
  async fetchApiFromUrl(url3, specFormat) {
845043
845558
  const response = await fetch(url3, { signal: AbortSignal.timeout(FETCH_API_SPEC_REQUEST_TIMEOUT_MS) });
845044
845559
  if (!response.ok) {
845045
- throw new Error(`HTTP ${response.status} ${response.statusText}`);
845560
+ throw new CliError({
845561
+ message: `HTTP ${response.status} ${response.statusText}`,
845562
+ code: CliError.Code.NetworkError
845563
+ });
845046
845564
  }
845047
845565
  const content5 = await response.text();
845048
845566
  const filename = this.resolveFilenameFromUrl({ url: url3, specFormat });
@@ -846572,20 +847090,29 @@ var ApiSpecDetector = class {
846572
847090
  async detect({ absoluteFilePath, reference: reference4, content: content5 }) {
846573
847091
  const parsed = this.parseOrThrow({ content: content5, reference: reference4 });
846574
847092
  if (typeof parsed !== "object" || parsed == null) {
846575
- throw new Error(`Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`);
847093
+ throw new CliError({
847094
+ message: `Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`,
847095
+ code: CliError.Code.InternalError
847096
+ });
846576
847097
  }
846577
847098
  for (const specType of DETECTABLE_SPEC_TYPES) {
846578
847099
  if (specType in parsed) {
846579
847100
  return specType;
846580
847101
  }
846581
847102
  }
846582
- throw new Error(`Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`);
847103
+ throw new CliError({
847104
+ message: `Could not determine API type for "${reference4}". File must contain a top-level "openapi" or "asyncapi" key.`,
847105
+ code: CliError.Code.InternalError
847106
+ });
846583
847107
  }
846584
847108
  parseOrThrow({ content: content5, reference: reference4 }) {
846585
847109
  try {
846586
847110
  return jsYaml.load(content5);
846587
847111
  } catch {
846588
- throw new Error(`Could not parse "${reference4}" as YAML or JSON. Ensure the file is a valid OpenAPI or AsyncAPI specification.`);
847112
+ throw new CliError({
847113
+ message: `Could not parse "${reference4}" as YAML or JSON. Ensure the file is a valid OpenAPI or AsyncAPI specification.`,
847114
+ code: CliError.Code.ParseError
847115
+ });
846589
847116
  }
846590
847117
  }
846591
847118
  };
@@ -846623,7 +847150,10 @@ var ApiSpecResolver = class {
846623
847150
  async resolveLocal({ reference: reference4 }) {
846624
847151
  const absoluteFilePath = resolve6(this.context.cwd, reference4);
846625
847152
  if (!await doesPathExist(absoluteFilePath)) {
846626
- throw new Error(`API spec file does not exist: ${reference4}`);
847153
+ throw new CliError({
847154
+ message: `API spec file does not exist: ${reference4}`,
847155
+ code: CliError.Code.ConfigError
847156
+ });
846627
847157
  }
846628
847158
  const content5 = await (0, import_promises92.readFile)(absoluteFilePath, "utf-8");
846629
847159
  const specType = await this.detector.detect({ absoluteFilePath, content: content5, reference: reference4 });
@@ -846636,11 +847166,17 @@ var ApiSpecResolver = class {
846636
847166
  async fetchContent({ url: url3 }) {
846637
847167
  const response = await fetch(url3, { signal: AbortSignal.timeout(FETCH_API_SPEC_REQUEST_TIMEOUT_MS) });
846638
847168
  if (!response.ok) {
846639
- throw new Error(`Failed to fetch "${url3}": HTTP ${response.status} ${response.statusText}`);
847169
+ throw new CliError({
847170
+ message: `Failed to fetch "${url3}": HTTP ${response.status} ${response.statusText}`,
847171
+ code: CliError.Code.NetworkError
847172
+ });
846640
847173
  }
846641
847174
  const contentType = response.headers.get("content-type") ?? "";
846642
847175
  if (contentType.includes("text/html")) {
846643
- throw new Error(`The URL "${url3}" returned HTML content. Ensure you're pointing to a raw spec URL, not a documentation page.`);
847176
+ throw new CliError({
847177
+ message: `The URL "${url3}" returned HTML content. Ensure you're pointing to a raw spec URL, not a documentation page.`,
847178
+ code: CliError.Code.ConfigError
847179
+ });
846644
847180
  }
846645
847181
  const content5 = await response.text();
846646
847182
  return { content: content5, contentType };
@@ -846665,7 +847201,10 @@ var ApiSpecResolver = class {
846665
847201
  case "asyncapi":
846666
847202
  return { asyncapi: absoluteFilePath, origin: origin2 };
846667
847203
  default:
846668
- throw new Error(`Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`);
847204
+ throw new CliError({
847205
+ message: `Unsupported spec type for flags mode: "${specType}". Supported: openapi, asyncapi`,
847206
+ code: CliError.Code.ConfigError
847207
+ });
846669
847208
  }
846670
847209
  }
846671
847210
  isUrl(reference4) {
@@ -847669,10 +848208,12 @@ var ContainerExecutionEnvironment = class {
847669
848208
  containerImage;
847670
848209
  keepContainer;
847671
848210
  runner;
847672
- constructor({ containerImage, keepContainer, runner, dockerImage, keepDocker }) {
848211
+ disableTelemetry;
848212
+ constructor({ containerImage, keepContainer, runner, disableTelemetry, dockerImage, keepDocker }) {
847673
848213
  this.containerImage = containerImage ?? dockerImage ?? "";
847674
848214
  this.keepContainer = keepContainer ?? keepDocker ?? false;
847675
848215
  this.runner = runner;
848216
+ this.disableTelemetry = disableTelemetry ?? false;
847676
848217
  }
847677
848218
  async execute({ generatorName, irPath, configPath, outputPath, snippetPath, snippetTemplatePath, licenseFilePath, sourceMounts, context: context3, inspect: inspect6, runner }) {
847678
848219
  context3.logger.info(`Executing generator ${generatorName} using container image: ${this.containerImage}`);
@@ -847699,16 +848240,29 @@ var ContainerExecutionEnvironment = class {
847699
848240
  envVars["NODE_OPTIONS"] = `--inspect-brk=0.0.0.0:${DEFAULT_NODE_DEBUG_PORT}`;
847700
848241
  ports[DEFAULT_NODE_DEBUG_PORT] = DEFAULT_NODE_DEBUG_PORT;
847701
848242
  }
847702
- await runContainer({
847703
- logger: context3.logger,
847704
- imageName: this.containerImage,
847705
- args: [CONTAINER_GENERATOR_CONFIG_PATH],
847706
- binds,
847707
- envVars,
847708
- ports,
847709
- removeAfterCompletion: !this.keepContainer,
847710
- runner: this.runner ?? runner
847711
- });
848243
+ if (this.disableTelemetry) {
848244
+ envVars["FERN_DISABLE_TELEMETRY"] = "true";
848245
+ }
848246
+ try {
848247
+ await runContainer({
848248
+ logger: context3.logger,
848249
+ imageName: this.containerImage,
848250
+ args: [CONTAINER_GENERATOR_CONFIG_PATH],
848251
+ binds,
848252
+ envVars,
848253
+ ports,
848254
+ removeAfterCompletion: !this.keepContainer,
848255
+ runner: this.runner ?? runner
848256
+ });
848257
+ } catch (error50) {
848258
+ if (error50 instanceof CliError) {
848259
+ throw error50;
848260
+ }
848261
+ throw new CliError({
848262
+ message: `Container execution failed: ${error50 instanceof Error ? error50.message : String(error50)}`,
848263
+ code: CliError.Code.ContainerError
848264
+ });
848265
+ }
847712
848266
  }
847713
848267
  };
847714
848268
 
@@ -873199,7 +873753,7 @@ var DynamicSnippetsJavaTestGenerator = class {
873199
873753
  }
873200
873754
  }
873201
873755
  } catch (e5) {
873202
- this.context.failAndThrow("Failed to run spotlessApply", e5);
873756
+ this.context.failAndThrow("Failed to run spotlessApply", e5, { code: CliError.Code.InternalError });
873203
873757
  }
873204
873758
  }
873205
873759
  this.context.logger.debug("Done generating dynamic snippet tests");
@@ -894776,11 +895330,17 @@ var DynamicSnippetsTypeScriptTestGenerator = class {
894776
895330
  buildGeneratorConfig(config5) {
894777
895331
  const outputMode = config5.output.mode;
894778
895332
  if (outputMode.type !== "github") {
894779
- throw new Error("GitHub output mode is required for TypeScript dynamic snippet tests");
895333
+ throw new CliError({
895334
+ message: "GitHub output mode is required for TypeScript dynamic snippet tests",
895335
+ code: CliError.Code.ConfigError
895336
+ });
894780
895337
  }
894781
895338
  const publishInfo = outputMode.publishInfo;
894782
895339
  if (!publishInfo || publishInfo.type !== "npm") {
894783
- throw new Error("NPM publish info is required for TypeScript dynamic snippet tests");
895340
+ throw new CliError({
895341
+ message: "NPM publish info is required for TypeScript dynamic snippet tests",
895342
+ code: CliError.Code.ConfigError
895343
+ });
894784
895344
  }
894785
895345
  return {
894786
895346
  ...config5,
@@ -894834,7 +895394,10 @@ var DynamicSnippetsTestGenerator = class _DynamicSnippetsTestGenerator {
894834
895394
  // ../generation/local-generation/local-workspace-runner/lib/dynamic-snippets/generateDynamicSnippetsTestSuite.js
894835
895395
  async function generateDynamicSnippetsTestSuite({ ir: ir10, config: config5 }) {
894836
895396
  if (ir10.dynamic == null) {
894837
- throw new Error("Internal error; dynamic IR is not available");
895397
+ throw new CliError({
895398
+ message: "Internal error; dynamic IR is not available",
895399
+ code: CliError.Code.InternalError
895400
+ });
894838
895401
  }
894839
895402
  return {
894840
895403
  ir: ir10.dynamic,
@@ -895030,7 +895593,10 @@ function getGeneratorConfig({ generatorInvocation, customConfig, workspaceName,
895030
895593
  push: (value3) => `https://github.com/${value3.owner}/${value3.repo}`,
895031
895594
  pullRequest: (value3) => `https://github.com/${value3.owner}/${value3.repo}`,
895032
895595
  _other: () => {
895033
- throw new Error("Encountered unknown github mode");
895596
+ throw new CliError({
895597
+ message: "Encountered unknown github mode",
895598
+ code: CliError.Code.InternalError
895599
+ });
895034
895600
  }
895035
895601
  });
895036
895602
  const outputConfig = {
@@ -895051,7 +895617,10 @@ function getGeneratorConfig({ generatorInvocation, customConfig, workspaceName,
895051
895617
  return outputConfig;
895052
895618
  },
895053
895619
  _other: () => {
895054
- throw new Error("Output type did not match any of the types supported by Fern");
895620
+ throw new CliError({
895621
+ message: "Output type did not match any of the types supported by Fern",
895622
+ code: CliError.Code.InternalError
895623
+ });
895055
895624
  }
895056
895625
  });
895057
895626
  return {
@@ -895925,7 +896494,10 @@ var LocalTaskHandler = class {
895925
896494
  return null;
895926
896495
  }
895927
896496
  if (!this.version) {
895928
- throw new Error("Version is required for auto versioning");
896497
+ throw new CliError({
896498
+ message: "Version is required for auto versioning",
896499
+ code: CliError.Code.InternalError
896500
+ });
895929
896501
  }
895930
896502
  let previousVersion;
895931
896503
  try {
@@ -896113,7 +896685,10 @@ var LocalTaskHandler = class {
896113
896685
  };
896114
896686
  }
896115
896687
  this.context.logger.error(`Failed to perform automatic versioning: ${error50}`);
896116
- throw new Error(`Automatic versioning failed: ${error50}`);
896688
+ throw new CliError({
896689
+ message: `Automatic versioning failed: ${error50}`,
896690
+ code: error50 instanceof CliError ? error50.code : CliError.Code.InternalError
896691
+ });
896117
896692
  } finally {
896118
896693
  if (diffFile) {
896119
896694
  try {
@@ -896166,7 +896741,7 @@ var LocalTaskHandler = class {
896166
896741
  incrementVersion(version7, versionBump) {
896167
896742
  const cleanVersion = import_semver13.default.clean(version7);
896168
896743
  if (!cleanVersion) {
896169
- throw new Error(`Invalid version format: ${version7}`);
896744
+ throw new CliError({ message: `Invalid version format: ${version7}`, code: CliError.Code.VersionError });
896170
896745
  }
896171
896746
  let releaseType;
896172
896747
  switch (versionBump) {
@@ -896180,11 +896755,17 @@ var LocalTaskHandler = class {
896180
896755
  releaseType = "patch";
896181
896756
  break;
896182
896757
  default:
896183
- throw new Error(`Unsupported version bump: ${versionBump}`);
896758
+ throw new CliError({
896759
+ message: `Unsupported version bump: ${versionBump}`,
896760
+ code: CliError.Code.VersionError
896761
+ });
896184
896762
  }
896185
896763
  const newVersion = import_semver13.default.inc(cleanVersion, releaseType);
896186
896764
  if (!newVersion) {
896187
- throw new Error(`Failed to increment version: ${version7}`);
896765
+ throw new CliError({
896766
+ message: `Failed to increment version: ${version7}`,
896767
+ code: CliError.Code.VersionError
896768
+ });
896188
896769
  }
896189
896770
  return version7.startsWith("v") ? `v${newVersion}` : newVersion;
896190
896771
  }
@@ -896244,7 +896825,10 @@ var LocalTaskHandler = class {
896244
896825
  */
896245
896826
  async getClientRegistry() {
896246
896827
  if (this.ai == null) {
896247
- throw new Error("No AI service configuration found in generators.yml. Please add an 'ai' section with provider and model.");
896828
+ throw new CliError({
896829
+ message: "No AI service configuration found in generators.yml. Please add an 'ai' section with provider and model.",
896830
+ code: CliError.Code.ConfigError
896831
+ });
896248
896832
  }
896249
896833
  this.context.logger.debug(`Using AI service: ${this.ai.provider} with model ${this.ai.model}`);
896250
896834
  return configureBamlClient(this.ai);
@@ -896482,7 +897066,7 @@ function extractLicenseFilePath(generatorInvocation, absolutePathToFernConfig) {
896482
897066
  }
896483
897067
  return void 0;
896484
897068
  }
896485
- async function writeFilesToDiskAndRunGenerator({ organization, absolutePathToFernConfig, workspace, generatorInvocation, absolutePathToLocalOutput, absolutePathToLocalSnippetJSON, absolutePathToLocalSnippetTemplateJSON, audiences, version: version7, workspaceTempDir, keepDocker, context: context3, irVersionOverride, outputVersionOverride, writeUnitTests, generateOauthClients, generatePaginatedClients, includeOptionalRequestPropertyExamples, inspect: inspect6, executionEnvironment, runner, whiteLabel, publishToRegistry, ir: ir10, ai: ai10, autoVersioningCache, absolutePathToSpecRepo, skipFernignore }) {
897069
+ async function writeFilesToDiskAndRunGenerator({ organization, absolutePathToFernConfig, workspace, generatorInvocation, absolutePathToLocalOutput, absolutePathToLocalSnippetJSON, absolutePathToLocalSnippetTemplateJSON, audiences, version: version7, workspaceTempDir, keepDocker, context: context3, irVersionOverride, outputVersionOverride, writeUnitTests, generateOauthClients, generatePaginatedClients, includeOptionalRequestPropertyExamples, inspect: inspect6, executionEnvironment, runner, whiteLabel, publishToRegistry, ir: ir10, ai: ai10, autoVersioningCache, absolutePathToSpecRepo, skipFernignore, disableTelemetry }) {
896486
897070
  const { latest: latest2, migrated } = await getIntermediateRepresentation({
896487
897071
  workspace,
896488
897072
  audiences,
@@ -896527,7 +897111,8 @@ async function writeFilesToDiskAndRunGenerator({ organization, absolutePathToFer
896527
897111
  }
896528
897112
  const environment2 = executionEnvironment ?? new ContainerExecutionEnvironment({
896529
897113
  containerImage: generatorInvocation.containerImage ? `${generatorInvocation.containerImage}:${generatorInvocation.version}` : `${generatorInvocation.name}:${generatorInvocation.version}`,
896530
- keepContainer: keepDocker
897114
+ keepContainer: keepDocker,
897115
+ disableTelemetry
896531
897116
  });
896532
897117
  const paths = environment2.usesContainerPaths ? {
896533
897118
  outputDirectory: AbsoluteFilePath2.of(CONTAINER_CODEGEN_OUTPUT_DIRECTORY),
@@ -896653,7 +897238,7 @@ function getGeneratorOutputSubfolder(generatorName) {
896653
897238
  }
896654
897239
 
896655
897240
  // ../generation/local-generation/local-workspace-runner/lib/runLocalGenerationForWorkspace.js
896656
- async function runLocalGenerationForWorkspace({ token, projectConfig, workspace, generatorGroup, version: version7, keepDocker, inspect: inspect6, context: context3, absolutePathToPreview, runner, ai: ai10, replay, noReplay, validateWorkspace, requireEnvVars, skipFernignore, publishToRegistry, isPreview: isPreviewOverride, automationMode, autoMerge }) {
897241
+ async function runLocalGenerationForWorkspace({ token, projectConfig, workspace, generatorGroup, version: version7, keepDocker, inspect: inspect6, context: context3, absolutePathToPreview, runner, ai: ai10, replay, noReplay, validateWorkspace, requireEnvVars, skipFernignore, publishToRegistry, isPreview: isPreviewOverride, automationMode, autoMerge, disableTelemetry }) {
896657
897242
  const userProvidedVersion = version7;
896658
897243
  if (userProvidedVersion != null) {
896659
897244
  if (absolutePathToPreview != null) {
@@ -896677,7 +897262,9 @@ async function runLocalGenerationForWorkspace({ token, projectConfig, workspace,
896677
897262
  const substituteEnvVars = (stringOrObject) => replaceEnvVariables(stringOrObject, {
896678
897263
  onError: (e5) => {
896679
897264
  if (!isPreview && (requireEnvVars ?? true)) {
896680
- interactiveTaskContext.failAndThrow(e5);
897265
+ interactiveTaskContext.failAndThrow(e5, void 0, {
897266
+ code: CliError.Code.EnvironmentError
897267
+ });
896681
897268
  }
896682
897269
  }
896683
897270
  }, { substituteAsEmpty: isPreview });
@@ -896730,13 +897317,13 @@ async function runLocalGenerationForWorkspace({ token, projectConfig, workspace,
896730
897317
  if (generatorInvocation.absolutePathToLocalOutput == null) {
896731
897318
  token ??= await getAccessToken();
896732
897319
  if (token == null) {
896733
- interactiveTaskContext.failWithoutThrowing("Please provide a FERN_TOKEN in your environment.");
897320
+ interactiveTaskContext.failWithoutThrowing("Please provide a FERN_TOKEN in your environment.", void 0, { code: CliError.Code.AuthError });
896734
897321
  return;
896735
897322
  }
896736
897323
  }
896737
897324
  const organization = await venus.organization.get(projectConfig.organization);
896738
897325
  if (generatorInvocation.absolutePathToLocalOutput == null && !organization.ok) {
896739
- interactiveTaskContext.failWithoutThrowing(`Failed to load details for organization ${projectConfig.organization}.`);
897326
+ interactiveTaskContext.failWithoutThrowing(`Failed to load details for organization ${projectConfig.organization}.`, void 0, { code: CliError.Code.NetworkError });
896740
897327
  return;
896741
897328
  }
896742
897329
  if (organization.ok) {
@@ -896772,7 +897359,7 @@ generators:
896772
897359
  uri: your-org/your-sdk-repo
896773
897360
  token: \${GITHUB_TOKEN}
896774
897361
  mode: pull-request
896775
- `);
897362
+ `, void 0, { code: CliError.Code.ConfigError });
896776
897363
  }
896777
897364
  }
896778
897365
  if (selfhostedGithubConfig != null) {
@@ -896806,13 +897393,13 @@ generators:
896806
897393
  const branchExists = await repo.remoteBranchExists(selfhostedGithubConfig.branch);
896807
897394
  if (!branchExists) {
896808
897395
  const parsedRepo = parseRepository(selfhostedGithubConfig.uri);
896809
- interactiveTaskContext.failAndThrow(`Branch ${selfhostedGithubConfig.branch} does not exist in repository ${parsedRepo.owner}/${parsedRepo.repo}`);
897396
+ interactiveTaskContext.failAndThrow(`Branch ${selfhostedGithubConfig.branch} does not exist in repository ${parsedRepo.owner}/${parsedRepo.repo}`, void 0, { code: CliError.Code.ConfigError });
896810
897397
  }
896811
897398
  }
896812
897399
  await repo.checkoutRemoteBranch(selfhostedGithubConfig.branch);
896813
897400
  }
896814
897401
  } catch (error50) {
896815
- interactiveTaskContext.failAndThrow(`Failed to clone GitHub repository ${selfhostedGithubConfig.uri}: ${extractErrorMessage(error50)}`);
897402
+ interactiveTaskContext.failAndThrow(`Failed to clone GitHub repository ${selfhostedGithubConfig.uri}: ${extractErrorMessage(error50)}`, void 0, { code: CliError.Code.NetworkError });
896816
897403
  }
896817
897404
  }
896818
897405
  let absolutePathToLocalSnippetJSON = void 0;
@@ -896852,7 +897439,8 @@ generators:
896852
897439
  ai: ai10,
896853
897440
  autoVersioningCache,
896854
897441
  absolutePathToSpecRepo: dirname6(workspace.absoluteFilePath),
896855
- skipFernignore
897442
+ skipFernignore,
897443
+ disableTelemetry
896856
897444
  });
896857
897445
  interactiveTaskContext.logger.info(source_default.green("Wrote files to " + absolutePathToLocalOutput));
896858
897446
  if (selfhostedGithubConfig != null && shouldCommit) {
@@ -896909,13 +897497,13 @@ generators:
896909
897497
  interactiveTaskContext.logger.info(source_default.green("Automerge enabled on PR"));
896910
897498
  }
896911
897499
  if (!pipelineResult.success) {
896912
- interactiveTaskContext.failAndThrow(`Post-generation pipeline failed: ${pipelineResult.errors?.join(", ")}`);
897500
+ interactiveTaskContext.failAndThrow(`Post-generation pipeline failed: ${pipelineResult.errors?.join(", ")}`, void 0, { code: CliError.Code.UserError });
896913
897501
  }
896914
897502
  }
896915
897503
  });
896916
897504
  }));
896917
897505
  if (results.some((didSucceed) => !didSucceed)) {
896918
- context3.failAndThrow();
897506
+ throw new TaskAbortSignal();
896919
897507
  }
896920
897508
  }
896921
897509
  function resolveAbsolutePathToLocalPreview(absolutePathToPreview, generatorInvocation) {
@@ -897118,7 +897706,7 @@ var GenerationRunner = class {
897118
897706
  const results = await Promise.all(generatorGroup.generators.map(async (generatorInvocation) => {
897119
897707
  return context3.runInteractiveTask({ name: generatorInvocation.name }, async (interactiveTaskContext) => {
897120
897708
  if (generatorInvocation.absolutePathToLocalOutput == null) {
897121
- interactiveTaskContext.failWithoutThrowing("Cannot generate because output location is not local-file-system");
897709
+ interactiveTaskContext.failWithoutThrowing("Cannot generate because output location is not local-file-system", void 0, { code: CliError.Code.ConfigError });
897122
897710
  return;
897123
897711
  }
897124
897712
  try {
@@ -897152,7 +897740,7 @@ var GenerationRunner = class {
897152
897740
  } catch (error50) {
897153
897741
  if (error50 instanceof TaskAbortSignal) {
897154
897742
  } else {
897155
- interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50);
897743
+ interactiveTaskContext.failWithoutThrowing(`Generation failed: ${error50 instanceof Error ? error50.message : "Unknown error"}`, error50, { code: error50 instanceof CliError ? error50.code : CliError.Code.InternalError });
897156
897744
  }
897157
897745
  }
897158
897746
  });
@@ -897161,7 +897749,7 @@ var GenerationRunner = class {
897161
897749
  async executeGenerator({ generatorGroup, generatorInvocation, context: context3, workspace, organization, irVersionOverride, outputVersionOverride, absolutePathToFernConfig, inspect: inspect6, skipFernignore, skipAutogenerationIfManualExamplesExist }) {
897162
897750
  context3.logger.info(`Starting generation for ${generatorInvocation.name}`);
897163
897751
  if (generatorInvocation.absolutePathToLocalOutput == null) {
897164
- throw new Error("Output path is required for generation");
897752
+ throw new CliError({ message: "Output path is required for generation", code: CliError.Code.ConfigError });
897165
897753
  }
897166
897754
  const rawIr = generateIntermediateRepresentation({
897167
897755
  workspace,
@@ -897467,7 +898055,10 @@ var LegacyGeneratorInvocationAdapter = class {
897467
898055
  }
897468
898056
  const absolutePath = join8(this.context.cwd, RelativeFilePath2.of(license));
897469
898057
  if (!await doesPathExist(absolutePath, "file")) {
897470
- throw new Error(`Custom license file "${absolutePath}" does not exist; did you mean to use either MIT or Apache-2.0?`);
898058
+ throw new CliError({
898059
+ message: `Custom license file "${absolutePath}" does not exist; did you mean to use either MIT or Apache-2.0?`,
898060
+ code: CliError.Code.InternalError
898061
+ });
897471
898062
  }
897472
898063
  const contents = await (0, import_promises106.readFile)(absolutePath, "utf-8");
897473
898064
  return api_exports4.GithubLicense.custom({ contents });
@@ -897650,7 +898241,8 @@ var LegacyLocalGenerationRunner = class {
897650
898241
  inspect: false,
897651
898242
  ai: void 0,
897652
898243
  skipFernignore: args.skipFernignore,
897653
- requireEnvVars: args.requireEnvVars
898244
+ requireEnvVars: args.requireEnvVars,
898245
+ disableTelemetry: !this.context.telemetry.isTelemetryEnabled()
897654
898246
  });
897655
898247
  if (taskContext.getResult() === TaskResult.Failure) {
897656
898248
  return {
@@ -897674,7 +898266,8 @@ var LegacyLocalGenerationRunner = class {
897674
898266
  const executionEnvironment = new ContainerExecutionEnvironment({
897675
898267
  containerImage,
897676
898268
  keepContainer: args.keepContainer ?? false,
897677
- runner: args.containerEngine
898269
+ runner: args.containerEngine,
898270
+ disableTelemetry: !this.context.telemetry.isTelemetryEnabled()
897678
898271
  });
897679
898272
  const runner = new GenerationRunner(executionEnvironment);
897680
898273
  await runner.run({
@@ -897975,7 +898568,10 @@ var SdkTask = class {
897975
898568
  getTask() {
897976
898569
  const task = this.taskGroup.getTask(this.id);
897977
898570
  if (task == null) {
897978
- throw new Error(`Internal error; task '${this.id}' does not exist`);
898571
+ throw new CliError({
898572
+ message: `Internal error; task '${this.id}' does not exist`,
898573
+ code: CliError.Code.InternalError
898574
+ });
897979
898575
  }
897980
898576
  return task;
897981
898577
  }
@@ -898207,7 +898803,7 @@ var GenerateCommand = class {
898207
898803
  }
898208
898804
  async runGeneration({ context: context3, workspace, targets: targets2, args, forceLocal }) {
898209
898805
  if (workspace.sdks == null) {
898210
- throw new Error("No SDKs configured");
898806
+ throw new CliError({ message: "No SDKs configured", code: CliError.Code.InternalError });
898211
898807
  }
898212
898808
  const apisToCheck = [...new Set(targets2.map((t3) => t3.api))];
898213
898809
  const apiChecker = new ApiChecker({
@@ -898889,7 +899485,10 @@ var GeneratorMigrator = class _GeneratorMigrator {
898889
899485
  const packageJsonContent = await (0, import_promises110.readFile)(packageJsonPath, "utf-8");
898890
899486
  const packageJson2 = JSON.parse(packageJsonContent);
898891
899487
  if (packageJson2.main == null) {
898892
- throw new Error(`No main field found in package.json for ${MIGRATION_PACKAGE_NAME}`);
899488
+ throw new CliError({
899489
+ message: `No main field found in package.json for ${MIGRATION_PACKAGE_NAME}`,
899490
+ code: CliError.Code.InternalError
899491
+ });
898893
899492
  }
898894
899493
  const packageEntryPoint = (0, import_path80.join)(packageDir, packageJson2.main);
898895
899494
  const { migrations } = await import((0, import_url8.pathToFileURL)(packageEntryPoint).href);
@@ -899004,11 +899603,14 @@ var GeneratorMigrator = class _GeneratorMigrator {
899004
899603
  this.logger.debug(`No migration package found for ${generatorName}.`);
899005
899604
  return void 0;
899006
899605
  }
899007
- throw new Error(`Failed to load generator migrations for ${generatorName}.
899606
+ throw new CliError({
899607
+ message: `Failed to load generator migrations for ${generatorName}.
899008
899608
 
899009
899609
  Reason: ${errorMessage}
899010
899610
 
899011
- Please check your internet connection and npm configuration, then try again.`);
899611
+ Please check your internet connection and npm configuration, then try again.`,
899612
+ code: CliError.Code.InternalError
899613
+ });
899012
899614
  }
899013
899615
  }
899014
899616
  /**
@@ -899037,7 +899639,10 @@ Please check your internet connection and npm configuration, then try again.`);
899037
899639
  const aVersion = import_semver14.default.parse(a4.version);
899038
899640
  const bVersion = import_semver14.default.parse(b7.version);
899039
899641
  if (aVersion == null || bVersion == null) {
899040
- throw new Error(`Internal error: Invalid migration version found during sort. Version A: ${a4.version}, Version B: ${b7.version}. This should not happen as invalid versions are filtered out.`);
899642
+ throw new CliError({
899643
+ message: `Internal error: Invalid migration version found during sort. Version A: ${a4.version}, Version B: ${b7.version}. This should not happen as invalid versions are filtered out.`,
899644
+ code: CliError.Code.InternalError
899645
+ });
899041
899646
  }
899042
899647
  return import_semver14.default.compare(aVersion, bVersion);
899043
899648
  });
@@ -899055,11 +899660,14 @@ Please check your internet connection and npm configuration, then try again.`);
899055
899660
  appliedVersions.push(migration23.version);
899056
899661
  } catch (error50) {
899057
899662
  const errorMessage = extractErrorMessage(error50);
899058
- throw new Error(`Failed to apply migration for version ${migration23.version}.
899663
+ throw new CliError({
899664
+ message: `Failed to apply migration for version ${migration23.version}.
899059
899665
 
899060
899666
  Reason: ${errorMessage}
899061
899667
 
899062
- Please report this issue at: https://github.com/fern-api/fern/issues`);
899668
+ Please report this issue at: https://github.com/fern-api/fern/issues`,
899669
+ code: CliError.Code.InternalError
899670
+ });
899063
899671
  }
899064
899672
  }
899065
899673
  return {
@@ -917803,13 +918411,17 @@ function reportError2(reporter, error50, options2) {
917803
918411
  }
917804
918412
  }
917805
918413
 
918414
+ // src/telemetry/isTelemetryDisabled.ts
918415
+ function isTelemetryDisabled() {
918416
+ return process.env.FERN_DISABLE_TELEMETRY === "true";
918417
+ }
918418
+
917806
918419
  // src/telemetry/SentryClient.ts
917807
918420
  var SentryClient = class {
917808
918421
  sentry;
917809
918422
  constructor({ release: release2 }) {
917810
- const isTelemetryEnabled = process.env.FERN_DISABLE_TELEMETRY !== "true";
917811
918423
  const sentryDsn = "https://84f58b5e457f06999d92f11ce4b79158@o4509504076185600.ingest.us.sentry.io/4511021546602496";
917812
- if (isTelemetryEnabled && sentryDsn != null && sentryDsn.length > 0) {
918424
+ if (!isTelemetryDisabled() && sentryDsn != null && sentryDsn.length > 0) {
917813
918425
  const sentryEnvironment = "development";
917814
918426
  if (sentryEnvironment == null || sentryEnvironment.length === 0) {
917815
918427
  throw new CliError({
@@ -917821,9 +918433,33 @@ var SentryClient = class {
917821
918433
  dsn: sentryDsn,
917822
918434
  release: release2,
917823
918435
  environment: sentryEnvironment,
918436
+ // Opt out of every built-in integration (HTTP tracing, local
918437
+ // variables, console breadcrumbs, etc.) — error capture is all
918438
+ // we need.
917824
918439
  defaultIntegrations: false,
917825
- integrations: [rewriteFramesIntegration()],
917826
- tracesSampleRate: 0
918440
+ // Rewrite absolute frame paths to repo-root-relative paths so
918441
+ // they align with the source maps uploaded at publish time.
918442
+ // onUncaughtException / onUnhandledRejection catch errors that
918443
+ // escape the CLI's top-level handler (fire-and-forget callbacks,
918444
+ // unhandled rejections in background work, etc.).
918445
+ // linkedErrors chains .cause so wrapped errors stay traceable.
918446
+ // nodeContext adds Node.js version and OS to every event.
918447
+ integrations: [
918448
+ rewriteFramesIntegration(),
918449
+ onUncaughtExceptionIntegration(),
918450
+ onUnhandledRejectionIntegration(),
918451
+ linkedErrorsIntegration(),
918452
+ nodeContextIntegration()
918453
+ ],
918454
+ // The CLI doesn't emit transactions; disable performance
918455
+ // sampling entirely.
918456
+ tracesSampleRate: 0,
918457
+ // Always attach a stack trace, even when the thrown value is
918458
+ // not an Error instance (e.g. a plain string or object).
918459
+ attachStacktrace: true,
918460
+ // Suppress the client-report envelope Sentry sends when events
918461
+ // are dropped (e.g. due to rate limits).
918462
+ sendClientReports: false
917827
918463
  });
917828
918464
  setSentryRunIdTags();
917829
918465
  }
@@ -918415,7 +919051,7 @@ var CliContext = class _CliContext {
918415
919051
  if (false) {
918416
919052
  this.logger.error("CLI_VERSION is not defined");
918417
919053
  }
918418
- return "4.81.1";
919054
+ return "4.82.0-1-g000d7384e60";
918419
919055
  }
918420
919056
  getCliName() {
918421
919057
  if (false) {
@@ -920342,7 +920978,8 @@ async function generateWorkspace({
920342
920978
  requireEnvVars,
920343
920979
  skipFernignore,
920344
920980
  automationMode,
920345
- autoMerge
920981
+ autoMerge,
920982
+ disableTelemetry: isTelemetryDisabled()
920346
920983
  });
920347
920984
  } else if (token != null) {
920348
920985
  await runRemoteGenerationForAPIWorkspace({
@@ -931417,7 +932054,8 @@ async function sdkPreview({
931417
932054
  noReplay: true,
931418
932055
  validateWorkspace: true,
931419
932056
  publishToRegistry,
931420
- isPreview: true
932057
+ isPreview: true,
932058
+ disableTelemetry: isTelemetryDisabled()
931421
932059
  });
931422
932060
  });
931423
932061
  }