davsclaus commented on code in PR #28001:
URL: https://github.com/apache/camel/pull/28001#discussion_r4303237634


##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/IntegrationLauncherTest.java:
##########
@@ -101,6 +101,50 @@ void failureOutputKeepsTheCauseNotTheFrames(@TempDir Path 
dir) throws Exception
         assertThat(text.indexOf("is 
starting")).isLessThan(text.indexOf("Failed to create route"));
     }
 
+    @Test
+    void failureCauseIsTheErrorCamelRunPrintsAsItExits(@TempDir Path dir) 
throws Exception {
+        // the console of camel run with a copy of the route in beans.yaml, 
next to the route file
+        String duplicate = "Failed to create route because: Duplicate route 
ids detected: order-generator. Please correct"
+                           + " ids to be unique among all your routes.";
+        StringBuilder out = new StringBuilder();
+        out.append("Running integration with the following configuration:\n    
--kamelets-version=4.22.1\n");
+        out.append("2026-10-17 11:03:43.201  INFO 81710 --- [           main] 
org.apache.camel.main.MainSupport   :"
+                   + " Apache Camel (JBang) 4.24.0-SNAPSHOT is starting\n");
+        out.append("2026-10-17 11:03:43.640  WARN 81710 --- [           main] 
sl.yaml.common.YamlDeserializerBase :"
+                   + " YAML DSL compact notation detected in: 
file:./beans.yaml\n");
+        out.append("2026-10-17 11:03:43.652 ERROR 81710 --- [           main] 
org.apache.camel.main.MainSupport   :"
+                   + " Error starting Camel: 
org.apache.camel.FailedToCreateRouteException: " + duplicate + "\n");
+        out.append("org.apache.camel.FailedToCreateRouteException: 
").append(duplicate).append('\n');
+        out.append("\tat 
org.apache.camel.main.RoutesConfigurer.addDiscoveredRoutes(RoutesConfigurer.java:385)\n");
+        out.append("\tat main.CamelJBang.main(CamelJBang.java:38)\n");
+        out.append("ERROR: ").append(duplicate).append('\n');
+        out.append("org.apache.camel.FailedToCreateRouteException: 
").append(duplicate).append('\n');
+        out.append("\tat 
org.apache.camel.main.RoutesConfigurer.addDiscoveredRoutes(RoutesConfigurer.java:385)\n");
+        Path output = dir.resolve("camel-launch.log");
+        Files.writeString(output, out.toString());
+
+        
assertThat(IntegrationLauncher.failureCause(output)).isEqualTo(duplicate);
+    }
+
+    @Test
+    void failureCauseWithoutTheErrorLineIsTheFirstLoggedException(@TempDir 
Path dir) throws Exception {
+        Path output = dir.resolve("camel-launch.log");
+        Files.writeString(output, "2026-10-06 01:12:03.101  INFO 81990 --- [   
        main] o.a.c.main.MainSupport  :"
+                                  + " Apache Camel (JBang) 4.24.0-SNAPSHOT is 
starting\n"
+                                  + "2026-10-06 01:12:04.552 ERROR 81990 --- [ 
          main] o.a.c.main.MainSupport  :"
+                                  + " Failed to create route: 
order-generator\n"
+                                  + 
"org.apache.camel.FailedToCreateRouteException: Failed to create route: 
order-generator"
+                                  + " because of No bean could be found in the 
registry for: orderNumber\n"
+                                  + "\tat 
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:1)\n");
+        assertThat(IntegrationLauncher.failureCause(output))
+                .isEqualTo("Failed to create route: order-generator because of 
No bean could be found in the registry for:"
+                           + " orderNumber");
+
+        // nothing that names an error: no cause, the output says what it says
+        Files.writeString(output, "Downloading dependency 
org.example:missing:1.0\n");
+        assertThat(IntegrationLauncher.failureCause(output)).isNull();
+    }

Review Comment:
   Added in 8a4e9a3173a5: an ERROR record with only a stack frame after it, and 
the cause is the message after " : ".
   
   _Claude Code on behalf of davsclaus_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to