public abstract class ErrorReporter extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ErrorReporter.Checkpoint
Opaque token, used by
checkpoint() and errorsSince(com.google.template.soy.error.ErrorReporter.Checkpoint). |
| Constructor and Description |
|---|
ErrorReporter() |
| Modifier and Type | Method and Description |
|---|---|
ErrorReporter.Checkpoint |
checkpoint()
Returns an opaque token (the checkpoint) that callers can later pass back into
errorsSince(com.google.template.soy.error.ErrorReporter.Checkpoint) to see if any errors have occurred in the interim. |
static ErrorReporter |
create(Map<String,SoyFileSupplier> filePathsToSuppliers)
Creates a new ErrorReporter which can create source snippets from the given files.
|
static ErrorReporter |
createForTest()
Creates a new ErrorReporter suitable for asserting on messages in tests.
|
boolean |
errorsSince(ErrorReporter.Checkpoint checkpoint)
Returns true iff errors have occurred since
checkpoint was obtained from checkpoint(). |
static ErrorReporter |
explodeOnErrorsAndIgnoreWarnings()
Returns an ErrorReporter that throws assertion error on every error but ignores warnings.
|
static ErrorReporter |
exploding()
Returns an ErrorReporter that throws an assertion error on every error and warning.
|
abstract com.google.common.collect.ImmutableList<SoyError> |
getErrors()
Returns all the errors reported so far.
|
abstract com.google.common.collect.ImmutableList<SoyError> |
getWarnings()
Returns all the warnings reported so far.
|
boolean |
hasErrors()
Returns true if any errors have been reported.
|
abstract void |
report(SourceLocation sourceLocation,
SoyErrorKind error,
Object... args)
Reports the given
error, formatted according to args and associated with the
given sourceLocation. |
abstract void |
warn(SourceLocation sourceLocation,
SoyErrorKind error,
Object... args)
Reports a warning.
|
public static ErrorReporter create(Map<String,SoyFileSupplier> filePathsToSuppliers)
public static ErrorReporter createForTest()
public static ErrorReporter exploding()
Useful for tests.
public static ErrorReporter explodeOnErrorsAndIgnoreWarnings()
public abstract void report(SourceLocation sourceLocation, SoyErrorKind error, Object... args)
error, formatted according to args and associated with the
given sourceLocation.public abstract void warn(SourceLocation sourceLocation, SoyErrorKind error, Object... args)
The formatting is identical to report(com.google.template.soy.base.SourceLocation, com.google.template.soy.error.SoyErrorKind, java.lang.Object...), but it will not cause the build to fail.
This should be used sparingly, the best usecase is to add warnings as part of a migration to
stop temporary backsliding.
public final ErrorReporter.Checkpoint checkpoint()
errorsSince(com.google.template.soy.error.ErrorReporter.Checkpoint) to see if any errors have occurred in the interim.public final boolean errorsSince(ErrorReporter.Checkpoint checkpoint)
checkpoint was obtained from checkpoint().
Useful for callers whose outputs are dependent on whether some code path resulted in new errors (for example, returning an error node if parsing encountered errors).
public final boolean hasErrors()
public abstract com.google.common.collect.ImmutableList<SoyError> getErrors()
public abstract com.google.common.collect.ImmutableList<SoyError> getWarnings()