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 d47b7d9f8f51606e3f2855025439961b10c28cb3
Author: Karl Heinz Marbaise <khmarba...@apache.org>
AuthorDate: Sat Nov 10 21:02:54 2018 +0100

    Added cause for debugging.
---
 .../enforcer/AbstractPropertyEnforcerRule.java     | 23 +++++++++++++++++++++-
 1 file changed, 22 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..ee344e6 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,31 @@ 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
      */

Reply via email to