T
- The class of exception that is collected.public class ErrorCollector<T extends Throwable> extends Object
Constructor and Description |
---|
ErrorCollector()
Creates a new error collector.
|
Modifier and Type | Method and Description |
---|---|
void |
collect(CollectedError.Level level,
T exception)
Collect an error reported by an underlying process such as a parser or a transformer.
|
void |
collectQuietly(CollectedError.Level level,
T exception)
Collect an error reported by an underlying process such as a parser or a transformer without
throwing any exception.
|
List<CollectedError<T>> |
getErrors()
Returns the list of collected errors.
|
boolean |
hasError()
Indicate whether any error was recorded by this error collector.
|
void |
setErrorFlag(CollectedError.Level threshold)
Set the threshold to set to rise the error flag.
|
void |
setException(CollectedError.Level threshold)
Set the threshold to throw an exception during the next collect operation.
|
public final void setException(CollectedError.Level threshold)
threshold
- the level at which the next collect call will throw an exception.NullPointerException
- If the threshold argument is null
.public final void setErrorFlag(CollectedError.Level threshold)
threshold
- the level at which the next collect call set the error flag to true
.NullPointerException
- If the threshold argument is null
.public final void collect(CollectedError.Level level, T exception) throws T extends Throwable
Note: this method should generally be called at the end of a function at it can throw an exception if the threshold was reached.
level
- The level of the exception.exception
- The exception thrown by the underlying process.T
- If the exception threshold has been reached, the exception passed as argument is thrown.NullPointerException
- If either argument is null
.T extends Throwable
public final void collectQuietly(CollectedError.Level level, T exception)
level
- The level of the exception.exception
- The exception thrown by the underlying process.NullPointerException
- If either argument is null
.public final List<CollectedError<T>> getErrors()
public final boolean hasError()
true
if any error was reported;
false
otherwise.Copyright © 2016 Allette Systems. All rights reserved.