Home / Function/ printErrorMessage() — react Function Reference

printErrorMessage() — react Function Reference

Architecture documentation for the printErrorMessage() function in CompilerError.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e39dece3_8891_8533_6625_5397539eb098["printErrorMessage()"]
  0fda7f86_b7a3_c1f2_f0d9_8d13eed4f042["CompilerDiagnostic"]
  e39dece3_8891_8533_6625_5397539eb098 -->|defined in| 0fda7f86_b7a3_c1f2_f0d9_8d13eed4f042
  4767de0a_dba6_b3df_77df_2b909825c02d["printErrorSummary()"]
  e39dece3_8891_8533_6625_5397539eb098 -->|calls| 4767de0a_dba6_b3df_77df_2b909825c02d
  073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"]
  e39dece3_8891_8533_6625_5397539eb098 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83
  c4a899b9_3ed3_b9e8_fdb0_decfd5276099["printCodeFrame()"]
  e39dece3_8891_8533_6625_5397539eb098 -->|calls| c4a899b9_3ed3_b9e8_fdb0_decfd5276099
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  e39dece3_8891_8533_6625_5397539eb098 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  87c7e084_efd0_e72a_89ba_0eea447fbc45["printErrorMessage()"]
  e39dece3_8891_8533_6625_5397539eb098 -->|calls| 87c7e084_efd0_e72a_89ba_0eea447fbc45
  style e39dece3_8891_8533_6625_5397539eb098 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts lines 165–208

  printErrorMessage(source: string, options: PrintErrorMessageOptions): string {
    const buffer = [printErrorSummary(this.category, this.reason)];
    if (this.description != null) {
      buffer.push('\n\n', `${this.description}.`);
    }
    for (const detail of this.options.details) {
      switch (detail.kind) {
        case 'error': {
          const loc = detail.loc;
          if (loc == null || typeof loc === 'symbol') {
            continue;
          }
          let codeFrame: string;
          try {
            codeFrame = printCodeFrame(source, loc, detail.message ?? '');
          } catch (e) {
            codeFrame = detail.message ?? '';
          }
          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);
          break;
        }
        case 'hint': {
          buffer.push('\n\n');
          buffer.push(detail.message);
          break;
        }
        default: {
          assertExhaustive(
            detail,
            `Unexpected detail kind ${(detail as any).kind}`,
          );
        }
      }
    }
    return buffer.join('');
  }

Domain

Subdomains

Frequently Asked Questions

What does printErrorMessage() do?
printErrorMessage() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts.
Where is printErrorMessage() defined?
printErrorMessage() is defined in compiler/packages/babel-plugin-react-compiler/src/CompilerError.ts at line 165.
What does printErrorMessage() call?
printErrorMessage() calls 5 function(s): assertExhaustive, printCodeFrame, printErrorMessage, printErrorSummary, push.

Analyze Your Own Codebase

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

Try Supermodel Free