Class JSError

java.lang.Object
com.google.javascript.jscomp.JSError
All Implemented Interfaces:
Serializable

public abstract class JSError extends Object implements Serializable
Compile error description.
See Also:
  • Method Details

    • getType

      public abstract DiagnosticType getType()
      A type of the error.
    • getDescription

      public abstract String getDescription()
      Description of the error.
    • getSourceName

      public abstract @Nullable String getSourceName()
      Name of the source
    • getLineno

      public abstract int getLineno()
      One-indexed line number of the error location.
    • getCharno

      public abstract int getCharno()
      Zero-indexed character number of the error location.
    • getLength

      public abstract int getLength()
      Length of the error region.
    • getNode

      public abstract @Nullable Node getNode()
      Node where the warning occurred.
    • getDefaultLevel

      public abstract CheckLevel getDefaultLevel()
      The default level, before any of the WarningsGuards are applied.
    • getRequirement

      public abstract @Nullable com.google.javascript.jscomp.Requirement getRequirement()
      Requirement that fails in the case of conformance violations.
    • make

      public static JSError make(DiagnosticType type, String... arguments)
      Creates a JSError with no source information
      Parameters:
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(String sourceName, int lineno, int charno, DiagnosticType type, String... arguments)
      Creates a JSError at a given source location
      Parameters:
      sourceName - The source file name
      lineno - Line number with source file, or -1 if unknown
      charno - Column number within line, or -1 for whole line.
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(Node n, DiagnosticType type, String... arguments)
      Creates a JSError from a file and Node position.
      Parameters:
      n - Determines the line and char position and source file name
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(Node start, Node end, DiagnosticType type, String... arguments)
      Creates a JSError from a file and Node position.
      Parameters:
      start - Determines the line and char position and source file name
      end - Determines the length of the error region
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • make

      public static JSError make(com.google.javascript.jscomp.Requirement requirement, Node n, DiagnosticType type, String... arguments)
      Creates a JSError from a requirement, file and Node position.
      Parameters:
      requirement - The conformance requirement that fails
      n - Determines the line and char position and source file name
      type - The DiagnosticType
      arguments - Arguments to be incorporated into the message
    • toString

      public final String toString()
      Overrides:
      toString in class Object
      Returns:
      the default rendering of an error as text.
    • format

      public final @Nullable String format(CheckLevel level, MessageFormatter formatter)
      Format a message at the given level.
      Returns:
      the formatted message or null
    • getNodeSourceOffset

      public final int getNodeSourceOffset()
      Returns:
      the offset of the region the Error applies to, or -1 if the offset is unknown.
    • getLineNumber

      public final int getLineNumber()
      Alias for getLineno().