From ae56c9b76e6628a2dabc19ef863eb47218ca21ca Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 25 Nov 2024 08:05:44 +0100 Subject: [PATCH] Thrown a more meaningful exception --- .../apache/maven/lifecycle/internal/concurrent/BuildPlan.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlan.java b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlan.java index 222a1ecd77e4..7e07c2de2830 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlan.java +++ b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlan.java @@ -25,6 +25,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; import java.util.function.Function; @@ -85,7 +86,7 @@ public Optional step(MavenProject project, String name) { } public BuildStep requiredStep(MavenProject project, String name) { - return step(project, name).get(); + return step(project, name).orElseThrow(() -> new NoSuchElementException("Step " + name + " not found")); } // add a follow-up plan to this one