public interface ErrorManager
Errors will come from 1) syntax validator plugins, 2) ParserException
s, which are usually thrown by core parsers or
custom refiners, or 3) SubscriptionException
s, which are usually caused by programming errors in plugin subscription
methods.
Modifier and Type | Method and Description |
---|---|
boolean |
autoSummarize()
Should return true if
summarize() should automatically be called at the end of parsing if there are errors and
the result wrapped and thrown by a new ProblemSummaryException . |
String |
getSourceName()
Gets the name of the source currently being parsed.
|
boolean |
hasErrors()
Returns true if there were any errors.
|
void |
report(ErrorLevel level,
Syntax cause,
String message)
Reports an error message.
|
void |
report(ParserException exception)
Reports an error based on a
ParserException . |
void |
report(SubscriptionException exception)
Reports an uncaught exception from a subscription method.
|
String |
summarize()
Returns a summary of errors.
|
String getSourceName()
void report(ErrorLevel level, Syntax cause, String message)
Validate
subscription methods.
Implementations should not throw or rethrow an exception from this method.
You can use ErrorUtils.format(Syntax, String)
as a helper.
level
- The ErrorLevel
.cause
- The Syntax
unit that is the cause of the error (e.g., the unit that has failed validation).message
- The error message.void report(ParserException exception)
ParserException
.
These are usually thrown by core parsers or custom refiner plugins, which is usually caused by bad CSS source code input.
exception
- The exception that describes the error.void report(SubscriptionException exception)
This will occur when a subscription plugin method throws an exception. This usually means there is a programming error in
the plugin, e.g., an NPE. It also might mean the plugin throws an unrelated (to the parser) exception which will results in
an InvocationTargetException
(this should be avoided).
Check the cause to find the underlying InvocationTargetException
.
exception
- The exception.boolean hasErrors()
boolean autoSummarize()
summarize()
should automatically be called at the end of parsing if there are errors and
the result wrapped and thrown by a new ProblemSummaryException
.summarize()
should be called automatically.String summarize()
If there are no errors then this should return an empty string.
Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.