From 1d19d44168b67799c95a243c437f56fd7b26fc35 Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Tue, 10 Sep 2024 16:43:31 +0200 Subject: [PATCH] chore: improve error message for duplicated PWA annotation (#19916) (#19928) --- .../server/frontend/scanner/FrontendDependencies.java | 9 +++++++-- .../server/frontend/scanner/FullDependenciesScanner.java | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FrontendDependencies.java b/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FrontendDependencies.java index c524d72d11c..a8f2503715d 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FrontendDependencies.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FrontendDependencies.java @@ -457,14 +457,19 @@ private void computePwaConfiguration() throws ClassNotFoundException { .getAnnotatedClasses(PWA.class.getName())) { if (!Arrays.asList(hopefullyAppShellClass.getInterfaces()) .contains(appShellConfiguratorClass)) { - throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION); + throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION + + " " + hopefullyAppShellClass.getName() + + " does not implement " + + AppShellConfigurator.class.getSimpleName()); } pwaVisitor.visitClass(hopefullyAppShellClass.getName()); } Set dependencies = pwaVisitor.getValues("name"); if (dependencies.size() > 1) { - throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION); + throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION + + " Found " + dependencies.size() + " implementations: " + + dependencies); } if (dependencies.isEmpty()) { this.pwaConfiguration = new PwaConfiguration(useV14Bootstrap); diff --git a/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FullDependenciesScanner.java b/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FullDependenciesScanner.java index 26c7f32bab3..4256f253b00 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FullDependenciesScanner.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/frontend/scanner/FullDependenciesScanner.java @@ -492,7 +492,9 @@ private PwaConfiguration discoverPwa() { if (annotatedClasses.isEmpty()) { return new PwaConfiguration(useV14Bootstrap); } else if (annotatedClasses.size() != 1) { - throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION); + throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION + + " Found " + annotatedClasses.size() + + " implementations: " + annotatedClasses); } Class hopefullyAppShellClass = annotatedClasses.iterator() @@ -501,7 +503,10 @@ private PwaConfiguration discoverPwa() { && !Arrays.stream(hopefullyAppShellClass.getInterfaces()) .map(Class::getName).collect(Collectors.toList()) .contains(AppShellConfigurator.class.getName())) { - throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION); + throw new IllegalStateException(ERROR_INVALID_PWA_ANNOTATION + + " " + hopefullyAppShellClass.getName() + + " does not implement " + + AppShellConfigurator.class.getSimpleName()); } Annotation pwa = annotationFinder