m-m-m / code

Library to parse, analyze, transform and generate code
Apache License 2.0
2 stars 3 forks source link

MavenBridgeImpl returns null on ModelBuildingException #34

Closed hohwille closed 2 years ago

hohwille commented 2 years ago

If computing the effective model results in a ModelBuildingException this is catched, logged and then null is returned: https://github.com/m-m-m/code/blob/92ef01aba4f112f28964d088278e65cfad1446ab/java/maven/src/main/java/net/sf/mmm/code/java/maven/impl/MavenBridgeImpl.java#L189

Instead I would expect we should throw the exception (converted as runtime exception) so callers can catch it and decide ow to handle it (e.g. enrich it with details). Currently the caller is unable to distinguish if he gets null because the POM did not exist at all or maven could not resolve a dependency and therefore was unable to compute the effective model.

hohwille commented 2 years ago

As a result in case of a ModelBuildingException the following code can cause an exception with a wrong message causing confusion. https://github.com/m-m-m/code/blob/632393e544504754b3d391a9a36e0ddeccdcbc48/java/impl/src/main/java/net/sf/mmm/code/impl/java/source/maven/JavaSourceProviderUsingMaven.java#L179