You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2009/04/20 07:32:21 UTC

svn commit: r766580 - /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/XNIException.java

Author: mrglavas
Date: Mon Apr 20 05:32:20 2009
New Revision: 766580

URL: http://svn.apache.org/viewvc?rev=766580&view=rev
Log:
JIRA Issue #1368:
http://issues.apache.org/jira/browse/XERCESJ-1368

Adding support for exception chaining to XNIException. In a JDK 1.4+ 
environment printStackTrace() will show the chained exceptions.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/XNIException.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/XNIException.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/XNIException.java?rev=766580&r1=766579&r2=766580&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/XNIException.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xni/XNIException.java Mon Apr 20 05:32:20 2009
@@ -42,7 +42,7 @@
     //
 
     /** The wrapped exception. */
-    private Exception fException;
+    private Exception fException = this;
 
     //
     // Constructors
@@ -84,7 +84,37 @@
 
     /** Returns the wrapped exception. */
     public Exception getException() {
-        return fException;
+        return fException != this ? fException : null;
     } // getException():Exception
+    
+    /**
+     * Initializes the cause of this <code>XNIException</code>.
+     * The value must be an instance of <code>Exception</code> or
+     * <code>null</code>.
+     * 
+     * @param throwable the cause
+     * @return this exception
+     * 
+     * @throws IllegalStateException if a cause has already been set
+     * @throws IllegalArgumentException if the cause is this exception
+     * @throws ClassCastException if the cause is not assignable to <code>Exception</code>
+     */
+    public synchronized Throwable initCause(Throwable throwable) {
+        if (fException != this) {
+            // TODO: Add error message.
+            throw new IllegalStateException();
+        }
+        if (throwable == this) {
+            // TODO: Add error message.
+            throw new IllegalArgumentException();
+        }
+        fException = (Exception) throwable;
+        return this;
+    } // initCause(Throwable):Throwable
+    
+    /** Returns the cause of this <code>XNIException</code>. */
+    public Throwable getCause() {
+        return getException();
+    } // getCause():Throwable
 
-} // class QName
+} // class XNIException



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org