Package com.google.javascript.jscomp
Class JSError
java.lang.Object
com.google.javascript.jscomp.JSError
- All Implemented Interfaces:
Serializable
Compile error description.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfinal @Nullable Stringformat(CheckLevel level, MessageFormatter formatter) Format a message at the given level.abstract intZero-indexed character number of the error location.abstract CheckLevelThe default level, before any of theWarningsGuards are applied.abstract StringDescription of the error.abstract intLength of the error region.abstract intOne-indexed line number of the error location.final intAlias forgetLineno().abstract @Nullable NodegetNode()Node where the warning occurred.final intabstract @Nullable com.google.javascript.jscomp.RequirementRequirement that fails in the case of conformance violations.abstract @Nullable StringName of the sourceabstract DiagnosticTypegetType()A type of the error.static JSErrormake(DiagnosticType type, String... arguments) Creates a JSError with no source informationstatic JSErrormake(com.google.javascript.jscomp.Requirement requirement, Node n, DiagnosticType type, String... arguments) Creates a JSError from a requirement, file and Node position.static JSErrormake(Node n, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSErrormake(Node start, Node end, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSErrormake(String sourceName, int lineno, int charno, DiagnosticType type, String... arguments) Creates a JSError at a given source locationfinal StringtoString()
-
Method Details
-
getType
A type of the error. -
getDescription
Description of the error. -
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
Node where the warning occurred. -
getDefaultLevel
The default level, before any of theWarningsGuards are applied. -
getRequirement
public abstract @Nullable com.google.javascript.jscomp.Requirement getRequirement()Requirement that fails in the case of conformance violations. -
make
Creates a JSError with no source information- Parameters:
type- The DiagnosticTypearguments- 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 namelineno- Line number with source file, or -1 if unknowncharno- Column number within line, or -1 for whole line.type- The DiagnosticTypearguments- Arguments to be incorporated into the message
-
make
Creates a JSError from a file and Node position.- Parameters:
n- Determines the line and char position and source file nametype- The DiagnosticTypearguments- Arguments to be incorporated into the message
-
make
Creates a JSError from a file and Node position.- Parameters:
start- Determines the line and char position and source file nameend- Determines the length of the error regiontype- The DiagnosticTypearguments- 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 failsn- Determines the line and char position and source file nametype- The DiagnosticTypearguments- Arguments to be incorporated into the message
-
toString
-
format
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 forgetLineno().
-