maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject [maven-enforcer] 01/01: Added cause for debugging.
Date Sat, 10 Nov 2018 21:40:41 GMT
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch IMPROVE_TESTS
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git

commit 662a7268f779ac79c68ba062351169c9673b184c
Author: Karl Heinz Marbaise <khmarbaise@apache.org>
AuthorDate: Sat Nov 10 21:02:54 2018 +0100

    Added cause for debugging.
---
 .../enforcer/AbstractPropertyEnforcerRule.java     | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractPropertyEnforcerRule.java
b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractPropertyEnforcerRule.java
index fade2a2..6ec5053 100755
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractPropertyEnforcerRule.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/AbstractPropertyEnforcerRule.java
@@ -117,10 +117,36 @@ public abstract class AbstractPropertyEnforcerRule
                 regexMessage = getName() + " \"" + getPropertyName() + "\" evaluates to \""
+ propValue + "\".  "
                     + "This does not match the regular expression \"" + regex + "\"";
             }
-            throw new EnforcerRuleException( regexMessage );
+            
+            Throwable cause = new Throwable( prettyOut( propValue.toString().getBytes() )
);
+            
+            throw new EnforcerRuleException( regexMessage, cause );
         }
     }
 
+    public String prettyOut( byte[] msg )
+    {
+        StringBuilder sb = new StringBuilder( msg.length * 2 );
+        for ( int j = 1; j < msg.length + 1; j++ )
+        {
+            if ( j % 16 == 1 || j == 0 )
+            {
+                if ( j != 0 )
+                {
+                    sb.append( System.lineSeparator() );
+                }
+                sb.append( String.format( "%04d  |  ", j / 16 ) );
+            }
+            sb.append( String.format( "%02X ", msg[j - 1] ) );
+            if ( j % 4 == 0 )
+            {
+                sb.append( " " );
+            }
+        }
+        sb.append( System.lineSeparator() );
+        return sb.toString();
+    }
+
     /**
      * How the property that is being evaluated is called
      */


Mime
View raw message