You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2012/02/06 11:26:54 UTC

svn commit: r1240965 - /santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java

Author: coheigea
Date: Mon Feb  6 10:26:54 2012
New Revision: 1240965

URL: http://svn.apache.org/viewvc?rev=1240965&view=rev
Log:
[SANTUARIO-297] - Exceptions should use a JDK exception cause mechanism

Modified:
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java?rev=1240965&r1=1240964&r2=1240965&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java Mon Feb  6 10:26:54 2012
@@ -64,9 +64,6 @@ public class XMLSecurityException extend
      */
     private static final long serialVersionUID = 1L;
 
-    /** Field originalException */
-    protected Exception originalException = null;
-
     /** Field msgID */
     protected String msgID;
 
@@ -78,7 +75,6 @@ public class XMLSecurityException extend
         super("Missing message string");
 
         this.msgID = null;
-        this.originalException = null;
     }
 
     /**
@@ -90,7 +86,6 @@ public class XMLSecurityException extend
         super(I18n.getExceptionMessage(msgID));
 
         this.msgID = msgID;
-        this.originalException = null;
     }
 
     /**
@@ -104,7 +99,6 @@ public class XMLSecurityException extend
         super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs));
 
         this.msgID = msgID;
-        this.originalException = null;
     }
 
     /**
@@ -118,9 +112,7 @@ public class XMLSecurityException extend
               + Constants.exceptionMessagesResourceBundleBase
               + "\". Original Exception was a "
               + originalException.getClass().getName() + " and message "
-              + originalException.getMessage());
-
-        this.originalException = originalException;
+              + originalException.getMessage(), originalException);
     }
 
     /**
@@ -130,10 +122,9 @@ public class XMLSecurityException extend
      * @param originalException
      */
     public XMLSecurityException(String msgID, Exception originalException) {
-        super(I18n.getExceptionMessage(msgID, originalException));
+        super(I18n.getExceptionMessage(msgID, originalException), originalException);
 
         this.msgID = msgID;
-        this.originalException = originalException;
     }
 
     /**
@@ -144,10 +135,9 @@ public class XMLSecurityException extend
      * @param originalException
      */
     public XMLSecurityException(String msgID, Object exArgs[], Exception originalException) {
-        super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs));
+        super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs), originalException);
 
         this.msgID = msgID;
-        this.originalException = originalException;
     }
 
     /**
@@ -173,8 +163,8 @@ public class XMLSecurityException extend
             message = s;
         }
 
-        if (originalException != null) {
-            message = message + "\nOriginal Exception was " + originalException.toString();
+        if (super.getCause() != null) {
+            message = message + "\nOriginal Exception was " + super.getCause().toString();
         }
 
         return message;
@@ -187,10 +177,6 @@ public class XMLSecurityException extend
     public void printStackTrace() {
         synchronized (System.err) {
             super.printStackTrace(System.err);
-
-            if (this.originalException != null) {
-                this.originalException.printStackTrace(System.err);
-            }
         }
     }
 
@@ -201,10 +187,6 @@ public class XMLSecurityException extend
      */
     public void printStackTrace(PrintWriter printwriter) {
         super.printStackTrace(printwriter);
-
-        if (this.originalException != null) {
-            this.originalException.printStackTrace(printwriter);
-        }
     }
 
     /**
@@ -214,10 +196,6 @@ public class XMLSecurityException extend
      */
     public void printStackTrace(PrintStream printstream) {
         super.printStackTrace(printstream);
-
-        if (this.originalException != null) {
-            this.originalException.printStackTrace(printstream);
-        }
     }
 
     /**
@@ -226,6 +204,9 @@ public class XMLSecurityException extend
      * @return the original exception
      */
     public Exception getOriginalException() {
-        return originalException;
+        if (this.getCause() instanceof Exception) {
+            return (Exception)this.getCause();
+        }
+        return null;
     }
 }