This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit 774419e2655847ac3310ca477864262989559501
Author: Richard Zowalla <[email protected]>
AuthorDate: Fri Sep 25 20:59:16 2026 +0200

    TOMEE-1619 record installer errors that come with an exception
---
 .../java/org/apache/tomee/installer/Alerts.java    |  7 +++-
 .../org/apache/tomee/installer/AlertsTest.java     | 46 ++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git 
a/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Alerts.java 
b/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Alerts.java
index 87d7aeaad8..7edecfb9dd 100644
--- a/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Alerts.java
+++ b/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Alerts.java
@@ -44,8 +44,13 @@ public class Alerts {
     }
 
     public void addError(final String message, final Exception e) {
-        // todo add exception somehow
+        if (e == null) {
+            addError(message);
+            return;
+        }
+        errors.add(message + ": " + e);
         System.out.println(message);
+        e.printStackTrace(System.out);
     }
 
     public boolean hasWarnings() {
diff --git 
a/tomee/tomee-common/src/test/java/org/apache/tomee/installer/AlertsTest.java 
b/tomee/tomee-common/src/test/java/org/apache/tomee/installer/AlertsTest.java
new file mode 100644
index 0000000000..fe9959f85e
--- /dev/null
+++ 
b/tomee/tomee-common/src/test/java/org/apache/tomee/installer/AlertsTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomee.installer;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class AlertsTest {
+    @Test
+    public void errorWithExceptionIsRecorded() {
+        final Alerts alerts = new Alerts();
+        alerts.addError("Unable to copy jar", new IOException("disk full"));
+
+        assertTrue(alerts.hasErrors());
+        assertEquals(1, alerts.getErrors().size());
+        assertTrue(alerts.getErrors().get(0).startsWith("Unable to copy jar"));
+        assertTrue(alerts.getErrors().get(0).contains("disk full"));
+    }
+
+    @Test
+    public void errorWithoutException() {
+        final Alerts alerts = new Alerts();
+        alerts.addError("Unable to copy jar", null);
+
+        assertEquals(1, alerts.getErrors().size());
+        assertEquals("Unable to copy jar", alerts.getErrors().get(0));
+    }
+}

Reply via email to