You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2018/12/09 13:01:02 UTC
[maven-enforcer] 01/01: [MENFORCER-314] - Warn if
EnforcerRuleException has no message
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch MENFORCER-314
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git
commit 9e00adf96db69ca34f99241b265b28a2c090e6b6
Author: Falko Modler <fa...@users.noreply.github.com>
AuthorDate: Sat Oct 27 17:07:02 2018 +0200
[MENFORCER-314] - Warn if EnforcerRuleException has no message
This should help to find out why DependencyConvergence
sometimes fails without providing a message.
---
.../apache/maven/plugins/enforcer/EnforceMojo.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
index 3fa2b3b..c4c76c0 100644
--- a/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
+++ b/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/EnforceMojo.java
@@ -217,16 +217,27 @@ public class EnforceMojo
}
else
{
+ // log a warning in case the exception message is missing
+ // so that the user can figure out what is going on
+ final String exceptionMessage = e.getMessage();
+ if ( exceptionMessage != null )
+ {
+ log.debug( "Adding " + level + " message due to exception", e );
+ }
+ else
+ {
+ log.warn( "Rule " + i + ": " + currentRule + " failed without a message", e );
+ }
+ // add the 'failed/warned' message including exceptionMessage
+ // which might be null in rare cases
if ( level == EnforcerLevel.ERROR )
{
hasErrors = true;
- list.add( "Rule " + i + ": " + currentRule + " failed with message:\n" + e.getMessage() );
- log.debug( "Adding failure due to exception", e );
+ list.add( "Rule " + i + ": " + currentRule + " failed with message:\n" + exceptionMessage );
}
else
{
- list.add( "Rule " + i + ": " + currentRule + " warned with message:\n" + e.getMessage() );
- log.debug( "Adding warning due to exception", e );
+ list.add( "Rule " + i + ": " + currentRule + " warned with message:\n" + exceptionMessage );
}
}
}