You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vl...@apache.org on 2002/11/28 10:30:47 UTC
cvs commit: xml-xindice/java/src/org/apache/xindice/core FaultCodes.java
vladimir 2002/11/28 01:30:47
Modified: java/src/org/apache/xindice/core FaultCodes.java
Log:
use the chained exceptions. Ok we lose some
Revision Changes Path
1.8 +32 -74 xml-xindice/java/src/org/apache/xindice/core/FaultCodes.java
Index: FaultCodes.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/FaultCodes.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FaultCodes.java 31 Oct 2002 06:59:56 -0000 1.7
+++ FaultCodes.java 28 Nov 2002 09:30:47 -0000 1.8
@@ -1,5 +1,3 @@
-package org.apache.xindice.core;
-
/*
* The Apache Software License, Version 1.1
*
@@ -59,6 +57,8 @@
* $Id$
*/
+package org.apache.xindice.core;
+
import org.apache.xindice.util.XindiceException;
import org.xmldb.api.base.ErrorCodes;
@@ -505,77 +505,36 @@
return createXMLDBException(faultCode, null, e);
}
- /**
- * Creates an XMLDBException instance based
- * on the specified fault code, message, and Exception. If the Exception is a DBException,
- * it will extract any important information from it (like fault
- * codes and messages). If the exception is an instance of XindiceException,
- * the exception class name and message of any Throwable(s) available
- * via XindiceException.getCause will also be incorporated
- * into the message. If a chain of wrapped XindiceExceptions is available,
- * the chain will be followed incorporating the class name and message
- * at each level. NOTE: this should only be considered a temporary fix
- * until such time as the xmldb API can be refined to allow for wrapped
- * throwables in XMLDBException.
- *
- * @param faultCode the fault code for the created exception
- * @param e The Exception to use
- * @return An XMLDBException instance
- */
- public static XMLDBException createXMLDBException(int faultCode, String message, Exception e) {
- if ( e instanceof XMLDBException )
- return (XMLDBException)e;
-
- StringBuffer aMessage = message == null ? new StringBuffer() : new StringBuffer(message);
+ /**
+ * Creates an XMLDBException instance based
+ * on the specified fault code, message, and Exception. If the Exception is a DBException,
+ * it will extract any important information from it (like fault
+ * codes and messages). If the exception is an instance of XindiceException,
+ * the exception class name and message of any Throwable(s) available
+ * via XindiceException.getCause will also be incorporated
+ * into the message. If a chain of wrapped XindiceExceptions is available,
+ * the chain will be followed incorporating the class name and message
+ * at each level. NOTE: this should only be considered a temporary fix
+ * until such time as the xmldb API can be refined to allow for wrapped
+ * throwables in XMLDBException.
+ *
+ * @param faultCode the fault code for the created exception
+ * @param e The Exception to use
+ * @return An XMLDBException instance
+ */
+ public static XMLDBException createXMLDBException(int faultCode,
+ String message,
+ Exception e) {
+ if (e instanceof XMLDBException) {
+ return (XMLDBException) e;
+ }
+
+ if (e instanceof DBException) {
+ faultCode = ((DBException) e).faultCode;
+ }
- if( e instanceof XindiceException ) {
- if( e instanceof DBException ) {
- faultCode = ((DBException)e).faultCode;
- if(aMessage.length() == 0) {
- aMessage.append(getMessage(faultCode));
- }
- }
-
- if( e.getMessage() != null ) {
- if( aMessage.length() > 0 ) {
- aMessage.append(": ");
- }
- aMessage.append(e.getMessage());
- }
-
- // follow chained throwables
- Throwable aThrowable = ((XindiceException)e).getCause();
- while( aThrowable != null ) {
- aMessage.append(": Wrapping ");
- aMessage.append(aThrowable.getClass().getName());
- aMessage.append("(");
- if( aThrowable.getMessage() != null ) {
- aMessage.append("\"");
- aMessage.append(aThrowable.getMessage());
- aMessage.append("\"");
- }
- else if( aThrowable instanceof DBException ) {
- aMessage.append("\"");
- aMessage.append(getMessage(((DBException)aThrowable).faultCode));
- aMessage.append("\"");
- }
-
- aMessage.append(")");
- if(aThrowable instanceof XindiceException) {
- aThrowable = ((XindiceException)e).getCause();
- }
- else {
- aThrowable = null;
- }
- }
- } else {
- if(e.getMessage() != null) {
- aMessage.append(": ");
- aMessage.append(e.getMessage());
- }
- }
- return new XMLDBException(ErrorCodes.VENDOR_ERROR, faultCode, aMessage.toString());
- }
+ return new XMLDBException(ErrorCodes.VENDOR_ERROR, faultCode, message, e);
+ }
/**
* getFaultCodeType examines the provided exception to determine
@@ -642,4 +601,3 @@
return getMessage(getFaultCode(e));
}
}
-