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 classErrors.ErrorRepresents an error.static interfaceErrors.ErrorFormatterHelper interface to format an error string.static classErrors.SourceLocationSourceLocation 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 Modifier and Type Method Description voidenterContext(java.lang.String description, @Nullable java.lang.String source)Enters a new error context.voidexitContext()Exits the last entered error context.java.lang.StringgetAllErrorsAsString()Returns a string will all errors reported via this object.java.lang.StringgetContent()java.lang.StringgetDescription()Returns description of the currently active error context.intgetErrorCount()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.ImmutableIntArraygetLineOffsets()Returns the line offet positions for the currently active error context.java.lang.StringgetLocationAt(int position)Returns a location description at the current offset position.intgetLocationPosition(int line, int column)Returns the raw codepoint offset for the given line and column.Errors.SourceLocationgetPositionLocation(int position)Returns theSourceLocationfor the given codepoint offsetposition.java.util.Optional<java.lang.String>getSnippet(int line)Returns the snippet of source at the given line, if present.voidreportError(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 theSourceLocationfor 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
public void reportError(int position, java.lang.String message, java.lang.Object... args)Reports an error.
-
-