Package dev.cel.common.internal
Class Errors
- java.lang.Object
-
- dev.cel.common.internal.Errors
-
@Internal public final class Errors extends java.lang.Object
An object which manages error reporting. Enriches error messages by source context pointing to the position in the source where the error occurred.CEL Library Internals. Do Not Use.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Errors.Error
Represents an error.static interface
Errors.ErrorFormatter
Helper interface to format an error string.static class
Errors.SourceLocation
SourceLocation gives the line and column where an expression starts.
-
Constructor Summary
Constructors Constructor Description Errors(java.lang.String description, @Nullable java.lang.String source)
Creates an errors object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
enterContext(java.lang.String description, @Nullable java.lang.String source)
Enters a new error context.void
exitContext()
Exits the last entered error context.java.lang.String
getAllErrorsAsString()
Returns a string will all errors reported via this object.java.lang.String
getContent()
java.lang.String
getDescription()
Returns description of the currently active error context.int
getErrorCount()
Returns the number of errors reported via this object.com.google.common.collect.ImmutableList<Errors.Error>
getErrors()
Return the list of errors reported so far.com.google.common.primitives.ImmutableIntArray
getLineOffsets()
Returns the line offet positions for the currently active error context.java.lang.String
getLocationAt(int position)
Returns a location description at the current offset position.int
getLocationPosition(int line, int column)
Returns the raw codepoint offset for the given line and column.Errors.SourceLocation
getPositionLocation(int position)
Returns theSourceLocation
for the given codepoint offsetposition
.java.util.Optional<java.lang.String>
getSnippet(int line)
Returns the snippet of source at the given line, if present.void
reportError(int position, java.lang.String message, java.lang.Object... args)
Deprecated.Useinstead
void
reportError(long exprId, int position, java.lang.String message, java.lang.Object... args)
Reports an error.
-
-
-
Constructor Detail
-
Errors
public Errors(java.lang.String description, @Nullable java.lang.String source)
Creates an errors object.- Parameters:
description
- description of the root error context used in error messages, e.g. a filename.source
- the (optional) source string associated with the root error context.
-
-
Method Detail
-
enterContext
public void enterContext(java.lang.String description, @Nullable java.lang.String source)
Enters a new error context. Errors reported in this context will use given description and source.
-
exitContext
public void exitContext()
Exits the last entered error context.
-
getLineOffsets
public com.google.common.primitives.ImmutableIntArray getLineOffsets()
Returns the line offet positions for the currently active error context.
-
getContent
public java.lang.String getContent()
-
getDescription
public java.lang.String getDescription()
Returns description of the currently active error context.
-
getLocationAt
public java.lang.String getLocationAt(int position)
Returns a location description at the current offset position.
-
getLocationPosition
public int getLocationPosition(int line, int column)
Returns the raw codepoint offset for the given line and column.
-
getPositionLocation
public Errors.SourceLocation getPositionLocation(int position)
Returns theSourceLocation
for the given codepoint offsetposition
.
-
getSnippet
public java.util.Optional<java.lang.String> getSnippet(int line)
Returns the snippet of source at the given line, if present.
-
getErrorCount
public int getErrorCount()
Returns the number of errors reported via this object.
-
getErrors
public com.google.common.collect.ImmutableList<Errors.Error> getErrors()
Return the list of errors reported so far.
-
getAllErrorsAsString
public java.lang.String getAllErrorsAsString()
Returns a string will all errors reported via this object.
-
reportError
@Deprecated public void reportError(int position, java.lang.String message, java.lang.Object... args)
Deprecated.Useinstead
Note: Used by codegen
-
reportError
public void reportError(long exprId, int position, java.lang.String message, java.lang.Object... args)
Reports an error.
-
-