diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java index 63c8b7ec367bd..446a76981f181 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java @@ -697,10 +697,7 @@ static void validateBean(BeanInfo bean, List errors, List errors, List errors, List errors, List classLoadListeners = new ArrayList<>(); public QuarkusUnitTest setExpectedException(Class expectedException) { + return setExpectedException(expectedException, false); + } + + public QuarkusUnitTest setExpectedException(Class expectedException, boolean logMessage) { return assertException(t -> { Throwable i = t; boolean found = false; @@ -130,8 +134,10 @@ public QuarkusUnitTest setExpectedException(Class expectedE } i = i.getCause(); } - - assertTrue(found, "Build failed with wrong exception, expected " + expectedException + " but got " + t); + if (found && logMessage) { + System.out.println("Build failed with the expected exception:" + i); + } + assertTrue(found, "Build failed with a wrong exception, expected " + expectedException + " but got " + t); }); }