Home / Class/ CompilerError Class — react Architecture

CompilerError Class — react Architecture

Architecture documentation for the CompilerError class in CompilerError.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|defined in| e96f281e_f381_272d_2359_3e6a091c9a1d
  041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 041ca752_10c1_3cda_1f5c_02f44a01310e
  eaa25847_803a_a160_25ce_fa2699f69d1c["throwDiagnostic()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| eaa25847_803a_a160_25ce_fa2699f69d1c
  cf8d627e_c2f0_6cd4_e5fc_35f3c7005b64["throwTodo()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| cf8d627e_c2f0_6cd4_e5fc_35f3c7005b64
  4c1b8e2a_6a7c_702c_3acd_bbaa1cbcdc27["throwInvalidJS()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 4c1b8e2a_6a7c_702c_3acd_bbaa1cbcdc27
  73346565_783f_1426_1d29_3d461dabc0a1["throwInvalidReact()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 73346565_783f_1426_1d29_3d461dabc0a1
  f4dabc03_d648_e2d6_19ef_83872ae711d3["throwInvalidConfig()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| f4dabc03_d648_e2d6_19ef_83872ae711d3
  f22aa897_9419_712a_d84d_eb9e8581801f["throw()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| f22aa897_9419_712a_d84d_eb9e8581801f
  5a207168_ee92_cf3e_88f3_676a664d6583["constructor()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 5a207168_ee92_cf3e_88f3_676a664d6583
  9492b249_afb2_75c5_1b1d_a03534b881cf["message()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 9492b249_afb2_75c5_1b1d_a03534b881cf
  0ce970b2_5d95_e70b_84a7_d8306d937c82["toString()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 0ce970b2_5d95_e70b_84a7_d8306d937c82
  6a20f28b_fc1e_8208_a624_5583793f4029["withPrintedMessage()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 6a20f28b_fc1e_8208_a624_5583793f4029
  34f66651_e581_e609_943e_35ffa0dc79f5["printErrorMessage()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 34f66651_e581_e609_943e_35ffa0dc79f5
  7930cad6_ab99_ae3b_5cac_03042fe5727b["merge()"]
  e51fd0d2_bb38_cc97_7763_efe37f300a47 -->|method| 7930cad6_ab99_ae3b_5cac_03042fe5727b

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts lines 302–523

export class CompilerError extends Error {
  details: Array<CompilerErrorDetail | CompilerDiagnostic> = [];
  disabledDetails: Array<CompilerErrorDetail | CompilerDiagnostic> = [];
  printedMessage: string | null = null;

  static invariant(
    condition: unknown,
    options: {
      reason: CompilerDiagnosticOptions['reason'];
      description?: CompilerDiagnosticOptions['description'];
      message?: string | null;
      loc: SourceLocation;
    },
  ): asserts condition {
    if (!condition) {
      const errors = new CompilerError();
      errors.pushDiagnostic(
        CompilerDiagnostic.create({
          reason: options.reason,
          description: options.description ?? null,
          category: ErrorCategory.Invariant,
        }).withDetails({
          kind: 'error',
          loc: options.loc,
          message: options.message ?? options.reason,
        }),
      );
      throw errors;
    }
  }

  static throwDiagnostic(options: CompilerDiagnosticOptions): never {
    const errors = new CompilerError();
    errors.pushDiagnostic(new CompilerDiagnostic(options));
    throw errors;
  }

  static throwTodo(
    options: Omit<CompilerErrorDetailOptions, 'category'>,
  ): never {
    const errors = new CompilerError();
    errors.pushErrorDetail(
      new CompilerErrorDetail({
        ...options,
        category: ErrorCategory.Todo,
      }),
    );
    throw errors;
  }

  static throwInvalidJS(
    options: Omit<CompilerErrorDetailOptions, 'category'>,
  ): never {
    const errors = new CompilerError();
    errors.pushErrorDetail(
      new CompilerErrorDetail({
        ...options,
        category: ErrorCategory.Syntax,
      }),
    );
    throw errors;
  }

  static throwInvalidReact(options: CompilerErrorDetailOptions): never {
    const errors = new CompilerError();
    errors.pushErrorDetail(new CompilerErrorDetail(options));
    throw errors;
  }

  static throwInvalidConfig(
    options: Omit<CompilerErrorDetailOptions, 'category'>,
  ): never {
    const errors = new CompilerError();
    errors.pushErrorDetail(
      new CompilerErrorDetail({
        ...options,
        category: ErrorCategory.Config,
      }),
    );
    throw errors;
  }

Domain

Frequently Asked Questions

What is the CompilerError class?
CompilerError is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts.
Where is CompilerError defined?
CompilerError is defined in compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts at line 302.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free