This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new a36bb3f0f84 CAMEL-20892: Misleading error message when Kamelet misses
mandatory field value
a36bb3f0f84 is described below
commit a36bb3f0f847bec94dca4d3e46561f3121344a61
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jun 19 20:07:51 2024 +0200
CAMEL-20892: Misleading error message when Kamelet misses mandatory field
value
---
.../org/apache/camel/component/kamelet/KameletComponent.java | 11 ++++++-----
.../camel/component/kamelet/KameletNotFoundException.java | 8 +++++++-
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git
a/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java
b/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java
index 06b1ace5cd2..adb6d154fc0 100644
---
a/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java
+++
b/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java
@@ -56,7 +56,8 @@ import static
org.apache.camel.component.kamelet.Kamelet.PARAM_UUID;
*/
@Component(Kamelet.SCHEME)
public class KameletComponent extends DefaultComponent {
- private static final Logger LOGGER =
LoggerFactory.getLogger(KameletComponent.class);
+
+ private static final Logger LOG =
LoggerFactory.getLogger(KameletComponent.class);
private final LifecycleHandler lifecycleHandler = new LifecycleHandler();
@@ -422,12 +423,12 @@ public class KameletComponent extends DefaultComponent {
final String uuid = (String)
endpoint.getKameletProperties().get(PARAM_UUID);
if (context.getRouteTemplateDefinition(templateId) == null && loc
!= null) {
- LOGGER.debug("Loading route template={} from {}", templateId,
loc);
+ LOG.debug("Loading route template={} from {}", templateId,
loc);
RouteTemplateHelper.loadRouteTemplateFromLocation(getCamelContext(),
routeTemplateLoaderListener, templateId,
loc);
}
- LOGGER.debug("Creating route from template={} and id={}",
templateId, routeId);
+ LOG.debug("Creating route from template={} and id={}", templateId,
routeId);
try {
String id = context.addRouteFromTemplate(routeId, templateId,
uuid, endpoint.getKameletProperties());
RouteDefinition def = context.getRouteDefinition(id);
@@ -439,7 +440,7 @@ public class KameletComponent extends DefaultComponent {
context.startRouteDefinitions(Collections.singletonList(def));
}
- LOGGER.debug("Route with id={} created from template={}", id,
templateId);
+ LOG.debug("Route with id={} created from template={}", id,
templateId);
} catch (Exception e) {
throw new KameletNotFoundException(templateId, loc, e);
}
@@ -473,7 +474,7 @@ public class KameletComponent extends DefaultComponent {
throw RuntimeCamelException.wrapRuntimeException(e);
}
} else {
- LOGGER.debug("Tracking route template={} and id={}",
endpoint.getTemplateId(), endpoint.getRouteId());
+ LOG.debug("Tracking route template={} and id={}",
endpoint.getTemplateId(), endpoint.getRouteId());
this.endpoints.add(endpoint);
}
}
diff --git
a/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletNotFoundException.java
b/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletNotFoundException.java
index 80639130757..7cae67394bb 100644
---
a/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletNotFoundException.java
+++
b/components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletNotFoundException.java
@@ -21,13 +21,19 @@ import org.apache.camel.CamelException;
public class KameletNotFoundException extends CamelException {
private final String templateId;
+ private final String locations;
public KameletNotFoundException(String templateId, String locations,
Throwable cause) {
- super("Kamelet with id " + templateId + " not found in locations: " +
locations, cause);
+ super("Error loading or creating Kamelet with id " + templateId + "
(locations: " + locations + ")", cause);
this.templateId = templateId;
+ this.locations = locations;
}
public String getTemplateId() {
return templateId;
}
+
+ public String getLocations() {
+ return locations;
+ }
}