Class ProcessingException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
be.imgn.gaia.processing.ProcessingException
- All Implemented Interfaces:
Serializable
An error in the source, thrown to stop processing an element and report the error at a precise place: the element,
one of its annotations, or one attribute of that annotation, as
Diagnostics reports it.
context.forEach(elements.annotatedWith("com.example.Mapper"), mapper -> {
if (mapper.getKind() != ElementKind.INTERFACE) {
throw new ProcessingException("must be an interface", mapper, "com.example.Mapper");
}
// generate the mapper
});
ProcessingContext.forEach(Iterable, java.util.function.Consumer) reports it and goes on with the next
element. A StepProcessor reports one that escapes Step.process(AnnotatedElements), and goes on with
the next step. Any processor reports it with Diagnostics.error(ProcessingException). The report is an error,
which makes the compilation fail, with the message of the exception; its stack trace is not reported.
The element and the annotation belong to javac's model of one compilation, which is not serializable: the exception cannot be serialized either.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionProcessingException(String message, Element element) Creates an exception reporting an error on an element.ProcessingException(String message, Element element, String annotation) Creates an exception reporting an error on the annotation of a type of an element.ProcessingException(String message, Element element, String annotation, String attribute) Creates an exception reporting an error on an attribute of the annotation of a type of an element.ProcessingException(String message, Element element, AnnotationMirror annotation) Creates an exception reporting an error on an annotation of an element.ProcessingException(String message, Element element, AnnotationMirror annotation, String attribute) Creates an exception reporting an error on an attribute of an annotation of an element. -
Method Summary
Modifier and TypeMethodDescriptionReturns the annotation of the element the error is about.Returns the attribute of the annotation the error is about.element()Returns the element the error is about.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ProcessingException
-
ProcessingException
Creates an exception reporting an error on an annotation of an element.- Parameters:
message- the message of the errorelement- the element the error is aboutannotation- the annotation the error is about, as found on the element: one of its annotations, or one nested in the value of an attribute of those, as a repeatable annotation is in its container, or one a class inherits from a superclass, which is reported on the class- Throws:
IllegalArgumentException- if the annotation is not on the element
-
ProcessingException
Creates an exception reporting an error on the annotation of a type of an element.- Parameters:
message- the message of the errorelement- the element the error is aboutannotation- the fully qualified name of the type of the annotation the error is about- Throws:
IllegalArgumentException- if the element has no such annotation
-
ProcessingException
public ProcessingException(String message, Element element, AnnotationMirror annotation, String attribute) Creates an exception reporting an error on an attribute of an annotation of an element. If the annotation does not write the attribute, leaving it to its default, the error is reported on the annotation.- Parameters:
message- the message of the errorelement- the element the error is aboutannotation- the annotation, as found on the element: one of its annotations, or one nested in the value of an attribute of those, as a repeatable annotation is in its container, or one a class inherits from a superclass, which is reported on the classattribute- the name of the attribute the error is about- Throws:
IllegalArgumentException- if the annotation is not on the element, or has no such attribute
-
ProcessingException
Creates an exception reporting an error on an attribute of the annotation of a type of an element. If the annotation does not write the attribute, leaving it to its default, the error is reported on the annotation.- Parameters:
message- the message of the errorelement- the element the error is aboutannotation- the fully qualified name of the type of the annotationattribute- the name of the attribute the error is about- Throws:
IllegalArgumentException- if the element has no such annotation, or the annotation no such attribute
-
-
Method Details
-
element
-
annotation
Returns the annotation of the element the error is about.- Returns:
- the annotation; empty if the error is about the element as a whole
-
attribute
-