Skip to content

Commit

Permalink
chore: improve error message for duplicated PWA annotation (#19916) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollovati authored Sep 10, 2024
1 parent 8eeac7f commit 1d19d44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 1d19d44

Please sign in to comment.