Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHossfeld committed Sep 5, 2024
1 parent a1a6c2e commit 9038671
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@

import com.github.nalukit.nalu.client.component.AbstractComponentController;
import com.github.nalukit.nalu.client.component.AbstractController;
import com.github.nalukit.nalu.client.component.IsAbstractComponent;
import com.github.nalukit.nalu.client.component.IsComponent;
import com.github.nalukit.nalu.client.component.IsComponentCreator;
import com.github.nalukit.nalu.client.component.annotation.AcceptParameter;
import com.github.nalukit.nalu.client.component.annotation.Controller;
import com.github.nalukit.nalu.client.constraint.IsParameterConstraintRule;
import com.github.nalukit.nalu.client.constraint.annotation.ParameterConstraint;
import com.github.nalukit.nalu.processor.ProcessorException;
import com.github.nalukit.nalu.processor.ProcessorUtils;
Expand Down Expand Up @@ -95,11 +98,11 @@ private ControllerModel handleController()
// handle ...
TypeElement componentTypeElement = this.getComponentTypeElement(annotation);
if (componentTypeElement == null) {
throw new ProcessorException("Nalu-Processor: componentTypeElement is null");
throw new ProcessorException("Nalu-Processor: component is null");
}
TypeElement componentInterfaceTypeElement = this.getComponentInterfaceTypeElement(annotation);
if (componentInterfaceTypeElement == null) {
throw new ProcessorException("Nalu-Processor: @Controller - componentInterfaceTypeElement is null");
throw new ProcessorException("Nalu-Processor: @Controller - componentInterface is null");
}
TypeMirror componentTypeTypeMirror = this.getComponentType(controllerElement.asType());
// check and save the component type ...
Expand All @@ -109,7 +112,8 @@ private ControllerModel handleController()
ClassNameModel compareValue = new ClassNameModel(componentTypeTypeMirror.toString());
if (!metaModel.getComponentType()
.equals(compareValue)) {
throw new ProcessorException("Nalu-Processor: componentType of >>" + componentTypeElement +
throw new ProcessorException("Nalu-Processor: componentType of >>" +
componentTypeElement +
"<< is different (>>" +
metaModel.getComponentType()
.getClassName() +
Expand Down Expand Up @@ -189,7 +193,7 @@ private void handleAcceptParameters(RoundEnvironment roundEnvironment,

private TypeElement getRuleTypeElement(ParameterConstraint annotation) {
try {
annotation.rule();
Class<? extends IsParameterConstraintRule> ignore = annotation.rule();
} catch (MirroredTypeException exception) {
return (TypeElement) this.processingEnvironment.getTypeUtils()
.asElement(exception.getTypeMirror());
Expand All @@ -199,7 +203,7 @@ private TypeElement getRuleTypeElement(ParameterConstraint annotation) {

private TypeElement getComponentTypeElement(Controller annotation) {
try {
annotation.component();
Class<? extends IsAbstractComponent> ignore = annotation.component();
} catch (MirroredTypeException exception) {
return (TypeElement) this.processingEnvironment.getTypeUtils()
.asElement(exception.getTypeMirror());
Expand All @@ -209,7 +213,7 @@ private TypeElement getComponentTypeElement(Controller annotation) {

private TypeElement getComponentInterfaceTypeElement(Controller annotation) {
try {
annotation.componentInterface();
Class<? extends IsComponent<?, ?>> ignore = annotation.componentInterface();
} catch (MirroredTypeException exception) {
return (TypeElement) this.processingEnvironment.getTypeUtils()
.asElement(exception.getTypeMirror());
Expand Down Expand Up @@ -337,9 +341,7 @@ public Void visitTypeVariable(TypeVariable typeVariable,
// check generic!
if (!componentInterfaceTypeElement.toString()
.equals(result[0].toString())) {
throw new ProcessorException("Nalu-Processor: controller >>" +
element +
"<< is declared as IsComponentCreator, but the used reference of the component interface does not match with the one inside the controller.");
throw new ProcessorException("Nalu-Processor: controller >>" + element + "<< is declared as IsComponentCreator, but the used reference of the component interface does not match with the one inside the controller.");
}
return true;
}
Expand Down Expand Up @@ -408,7 +410,7 @@ private List<String> getRoute(String[] routes) {
if (tmpRoute.startsWith("/")) {
tmpRoute = tmpRoute.substring(1);
}
if (tmpRoute.length() == 0) {
if (tmpRoute.isEmpty()) {
convertedRoutes.add("/");
} else {
StringBuilder sbRoute = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.github.nalukit.nalu.processor.scanner;

import com.github.nalukit.nalu.client.component.AbstractCompositeController;
import com.github.nalukit.nalu.client.component.IsLoadCompositeCondition;
import com.github.nalukit.nalu.client.component.annotation.Composite;
import com.github.nalukit.nalu.client.component.annotation.Composite.Scope;
import com.github.nalukit.nalu.client.component.annotation.Composites;
Expand Down Expand Up @@ -74,7 +76,7 @@ public ControllerModel scan(RoundEnvironment roundEnvironment) {

private TypeElement getCompositeTypeElement(Composite annotation) {
try {
annotation.compositeController();
Class<? extends AbstractCompositeController<?, ?, ?>> ignore = annotation.compositeController();
} catch (MirroredTypeException exception) {
return (TypeElement) this.processingEnvironment.getTypeUtils()
.asElement(exception.getTypeMirror());
Expand All @@ -84,7 +86,7 @@ private TypeElement getCompositeTypeElement(Composite annotation) {

private TypeElement getCompositeConditionElement(Composite annotation) {
try {
annotation.condition();
Class<? extends IsLoadCompositeCondition> ignore = annotation.condition();
} catch (MirroredTypeException exception) {
return (TypeElement) this.processingEnvironment.getTypeUtils()
.asElement(exception.getTypeMirror());
Expand Down

0 comments on commit 9038671

Please sign in to comment.