Skip to content

improve error message for modules with duplicate names - #1758

Open
SamuelAdigos wants to merge 2 commits into
TNG:mainfrom
SamuelAdigos:fix/issue-1520-duplicate-module-name-message
Open

SamuelAdigos wants to merge 2 commits into
TNG:mainfrom
SamuelAdigos:fix/issue-1520-duplicate-module-name-message

Conversation

@SamuelAdigos

Copy link
Copy Markdown

So far, if multiple modules ended up with the same name, ArchModules threw an exception like Found multiple modules with the same name: [].
This was hard to understand, especially if the duplicate name was empty, e.g. when using jMolecules' @Module("Foo") with definedByAnnotation(Module.class), where name() is "" because the value was given via the value alias. The message looked like an empty list and didn't mention which modules were conflicting.

We now quote each duplicate name and list the (sorted) identifiers of the conflicting modules, e.g.

Found multiple modules with the same name: '' (modules with identifiers [com.myorg.annotation], [com.myorg.tool])

This change only affects the error message. Deriving the name from value() by default, as also suggested in the issue, is left out for now, since definedByAnnotation(Module.class, Module::value) already covers that use case and changing the default would be a behavioral change worth discussing separately.

Verified with ./gradlew clean build -PallTests.

Resolves #1520

So far, if multiple modules ended up with the same name, `ArchModules`
threw an exception like `Found multiple modules with the same name: []`.
This was hard to understand, especially if the duplicate name was empty,
e.g. when using jMolecules' `@Module("Foo")` with
`definedByAnnotation(Module.class)`, where `name()` is `""` because the
value was given via the `value` alias. The message looked like an empty
list and didn't mention which modules were conflicting.

We now quote each duplicate name and list the (sorted) identifiers
of the conflicting modules.

Resolves: TNG#1520
Signed-off-by: Samuel Vila <svila.smr@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modules doesn't respect value as an alias for name issues

1 participant