import java.util.concurrent.StructuredTaskScope; /** The JDK 25/26 way to catch a failed scope. FailedException is gone in 27. */ public class OldFailedException { public static void main(String[] args) throws Exception { try (var scope = StructuredTaskScope.open()) { scope.fork(() -> { throw new IllegalStateException("boom"); }); scope.join(); } catch (StructuredTaskScope.FailedException e) { System.out.println("cause: " + e.getCause()); } } }