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 String
format
(CheckLevel level, MessageFormatter formatter) Format a message at the given level.abstract int
Zero-indexed character number of the error location.abstract CheckLevel
The default level, before any of theWarningsGuard
s are applied.abstract String
Description of the error.abstract int
Length of the error region.abstract int
One-indexed line number of the error location.final int
Alias forgetLineno()
.abstract @Nullable Node
getNode()
Node where the warning occurred.final int
abstract @Nullable com.google.javascript.jscomp.Requirement
Requirement that fails in the case of conformance violations.abstract @Nullable String
Name of the sourceabstract DiagnosticType
getType()
A type of the error.static JSError
make
(DiagnosticType type, String... arguments) Creates a JSError with no source informationstatic JSError
make
(com.google.javascript.jscomp.Requirement requirement, Node n, DiagnosticType type, String... arguments) Creates a JSError from a requirement, file and Node position.static JSError
make
(Node n, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSError
make
(Node start, Node end, DiagnosticType type, String... arguments) Creates a JSError from a file and Node position.static JSError
make
(String sourceName, int lineno, int charno, DiagnosticType type, String... arguments) Creates a JSError at a given source locationfinal String
toString()
-
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 theWarningsGuard
s 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()
.
-