Home / Class/ CompilerErrorDetail Class — react Architecture

CompilerErrorDetail Class — react Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1["CompilerErrorDetail"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|defined in| e96f281e_f381_272d_2359_3e6a091c9a1d
  0c40fab4_5573_6533_fea8_298985e2eb68["constructor()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 0c40fab4_5573_6533_fea8_298985e2eb68
  45395d6e_6da5_537e_25ce_3e1cb8f0cfc2["reason()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 45395d6e_6da5_537e_25ce_3e1cb8f0cfc2
  c03db1e5_4fa1_d60a_bfae_a7576366b3dd["description()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| c03db1e5_4fa1_d60a_bfae_a7576366b3dd
  4917adde_d405_7b97_24a1_d175a53dd768["severity()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 4917adde_d405_7b97_24a1_d175a53dd768
  c430c8bc_f278_7b6c_a071_9b169f85b697["loc()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| c430c8bc_f278_7b6c_a071_9b169f85b697
  9c2ecbef_1cc7_6015_66f8_e966959c7213["suggestions()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 9c2ecbef_1cc7_6015_66f8_e966959c7213
  d18697e0_17a3_be77_d274_ff746b1f1092["category()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| d18697e0_17a3_be77_d274_ff746b1f1092
  808e0685_f81d_fe6a_783d_8e22e744f71a["primaryLocation()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 808e0685_f81d_fe6a_783d_8e22e744f71a
  87c7e084_efd0_e72a_89ba_0eea447fbc45["printErrorMessage()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 87c7e084_efd0_e72a_89ba_0eea447fbc45
  6983a759_4292_21b5_9f66_54a811585642["toString()"]
  7cb692eb_ba8e_04dc_5f67_df48b332c3c1 -->|method| 6983a759_4292_21b5_9f66_54a811585642

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts lines 229–295

export class CompilerErrorDetail {
  options: CompilerErrorDetailOptions;

  constructor(options: CompilerErrorDetailOptions) {
    this.options = options;
  }

  get reason(): CompilerErrorDetailOptions['reason'] {
    return this.options.reason;
  }
  get description(): CompilerErrorDetailOptions['description'] {
    return this.options.description;
  }
  get severity(): ErrorSeverity {
    return getRuleForCategory(this.category).severity;
  }
  get loc(): CompilerErrorDetailOptions['loc'] {
    return this.options.loc;
  }
  get suggestions(): CompilerErrorDetailOptions['suggestions'] {
    return this.options.suggestions;
  }
  get category(): ErrorCategory {
    return this.options.category;
  }

  primaryLocation(): SourceLocation | null {
    return this.loc;
  }

  printErrorMessage(source: string, options: PrintErrorMessageOptions): string {
    const buffer = [printErrorSummary(this.category, this.reason)];
    if (this.description != null) {
      buffer.push(`\n\n${this.description}.`);
    }
    const loc = this.loc;
    if (loc != null && typeof loc !== 'symbol') {
      let codeFrame: string;
      try {
        codeFrame = printCodeFrame(source, loc, this.reason);
      } catch (e) {
        codeFrame = '';
      }
      buffer.push(`\n\n`);
      if (loc.filename != null) {
        const line = loc.start.line;
        const column = options.eslint ? loc.start.column + 1 : loc.start.column;
        buffer.push(`${loc.filename}:${line}:${column}\n`);
      }
      buffer.push(codeFrame);
      buffer.push('\n\n');
    }
    return buffer.join('');
  }

  toString(): string {
    const buffer = [printErrorSummary(this.category, this.reason)];
    if (this.description != null) {
      buffer.push(`. ${this.description}.`);
    }
    const loc = this.loc;
    if (loc != null && typeof loc !== 'symbol') {
      buffer.push(` (${loc.start.line}:${loc.start.column})`);
    }
    return buffer.join('');
  }
}

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free