summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-12-10 13:35:17 +0200
committerNoel Grandin <noel@peralex.com>2014-12-10 13:37:24 +0200
commitfd60dd5226b6cefb1eb621f8e479ba59bf11b0b7 (patch)
tree8508b20e7ed08bd11227551d3d57e7ce7a7e40d9
parent07c54fff7ad9da498acd482148e491b879766bd4 (diff)
java: improve use of WrappedTargetException to set cause properly
since we introduced the new constructors that pass the cause all the way up to java.lang.Throwable. Also simplify some exeception printing sites, because Throwable will correctly print out child exceptions for us. Change-Id: Ibbecce3c6f971fbc80d6de2052ab4f33a4503c0a
-rw-r--r--bridges/test/java_uno/nativethreadpool/Relay.java4
-rw-r--r--desktop/test/deployment/active/com/sun/star/comp/test/deployment/Dispatch.java2
-rw-r--r--desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java2
-rw-r--r--desktop/test/deployment/passive/com/sun/star/comp/test/deployment/Dispatch.java2
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java6
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java6
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java2
-rw-r--r--sfx2/qa/complex/sfx2/DocumentMetadataAccess.java20
-rw-r--r--sw/qa/complex/writer/LoadSaveTest.java21
-rw-r--r--unoxml/qa/complex/unoxml/RDFRepositoryTest.java21
10 files changed, 12 insertions, 74 deletions
diff --git a/bridges/test/java_uno/nativethreadpool/Relay.java b/bridges/test/java_uno/nativethreadpool/Relay.java
index fb1063b1308d..7b523f3210ab 100644
--- a/bridges/test/java_uno/nativethreadpool/Relay.java
+++ b/bridges/test/java_uno/nativethreadpool/Relay.java
@@ -43,7 +43,7 @@ public final class Relay implements XRelay, XSource {
} catch (RuntimeException e) {
throw e;
} catch (com.sun.star.uno.Exception e) {
- throw new WrappedTargetRuntimeException(e.getMessage(), this, e);
+ throw new WrappedTargetRuntimeException(e, e.getMessage(), this, e);
} catch (Exception e) {
throw new com.sun.star.uno.RuntimeException(e, "", this);
}
@@ -55,7 +55,7 @@ public final class Relay implements XRelay, XSource {
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
} catch (com.sun.star.uno.Exception e) {
- throw new WrappedTargetRuntimeException(e.getMessage(), this, e);
+ throw new WrappedTargetRuntimeException(e, e.getMessage(), this, e);
}
new Thread() {
@Override
diff --git a/desktop/test/deployment/active/com/sun/star/comp/test/deployment/Dispatch.java b/desktop/test/deployment/active/com/sun/star/comp/test/deployment/Dispatch.java
index f50cdeac59a5..e224c94183ee 100644
--- a/desktop/test/deployment/active/com/sun/star/comp/test/deployment/Dispatch.java
+++ b/desktop/test/deployment/active/com/sun/star/comp/test/deployment/Dispatch.java
@@ -77,7 +77,7 @@ public final class Dispatch extends WeakBase implements XServiceInfo, XDispatch
} catch (com.sun.star.uno.RuntimeException e) {
throw e;
} catch (com.sun.star.uno.Exception e) {
- throw new WrappedTargetRuntimeException(
+ throw new WrappedTargetRuntimeException(e,
"wrapped: " + e.getMessage(), this, e);
}
}
diff --git a/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java b/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java
index f7499ceef5f7..7cd3688176c4 100644
--- a/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java
+++ b/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java
@@ -135,7 +135,7 @@ public class OptionsEventHandler {
try {
return handleExternalEvent(aWindow, aEventObject);
} catch (com.sun.star.uno.Exception e) {
- throw new WrappedTargetException(sMethod, this, e);
+ throw new WrappedTargetException(e, sMethod, this, e);
}
}
diff --git a/desktop/test/deployment/passive/com/sun/star/comp/test/deployment/Dispatch.java b/desktop/test/deployment/passive/com/sun/star/comp/test/deployment/Dispatch.java
index 701fb3172e8a..74882bca55c4 100644
--- a/desktop/test/deployment/passive/com/sun/star/comp/test/deployment/Dispatch.java
+++ b/desktop/test/deployment/passive/com/sun/star/comp/test/deployment/Dispatch.java
@@ -77,7 +77,7 @@ public final class Dispatch extends WeakBase implements XServiceInfo, XDispatch
} catch (com.sun.star.uno.RuntimeException e) {
throw e;
} catch (com.sun.star.uno.Exception e) {
- throw new WrappedTargetRuntimeException(
+ throw new WrappedTargetRuntimeException(e,
"wrapped: " + e.getMessage(), this, e);
}
}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
index 47407b1e78ad..ed82d92a4870 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
@@ -688,11 +688,11 @@ XMultiPropertySet
}
catch (java.lang.NoSuchFieldException e)
{
- throw new WrappedTargetException("Field does not exist", this, e);
+ throw new WrappedTargetException(e, "Field does not exist", this, e);
}
catch (java.lang.IllegalAccessException e)
{
- throw new WrappedTargetException("", this ,e);
+ throw new WrappedTargetException(e, "", this ,e);
}
return ret;
}
@@ -808,7 +808,7 @@ XMultiPropertySet
}
catch(java.lang.Exception e)
{
- throw new WrappedTargetException("PropertySet.setPropertyValueNoBroadcast", this, e);
+ throw new WrappedTargetException(e, "PropertySet.setPropertyValueNoBroadcast", this, e);
}
}
/** Retrieves the value of a property. This implementation presumes that the values are stored in member variables
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
index 7e2af48e1e56..26d94649174a 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
@@ -479,7 +479,7 @@ public final class PropertySetMixin {
} catch (UnknownPropertyException e) {
continue;
} catch (WrappedTargetException e) {
- throw new WrappedTargetRuntimeException(e,
+ throw new WrappedTargetRuntimeException(e.getCause(),
e.getMessage(), object, e.TargetException);
}
s[n++] = new PropertyValue(handleMap[i], i, value, state[0]);
@@ -742,7 +742,7 @@ public final class PropertySetMixin {
{
throw new PropertyVetoException(e, name, object);
} else {
- throw new WrappedTargetException(
+ throw new WrappedTargetException(e.getCause(),
e.getMessage(), object, e.TargetException);
}
}
@@ -774,7 +774,7 @@ public final class PropertySetMixin {
{
throw new UnknownPropertyException(e, name, object);
} else {
- throw new WrappedTargetException(
+ throw new WrappedTargetException(e.getCause(),
e.getMessage(), object, e.TargetException);
}
}
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java
index 2b25f21fba1b..5238028cee55 100644
--- a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java
@@ -130,7 +130,7 @@ public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor
createDialog();
}
catch ( Exception e ) {
- throw new com.sun.star.lang.WrappedTargetRuntimeException( e.getMessage(), this, e );
+ throw new com.sun.star.lang.WrappedTargetRuntimeException( e, e.getMessage(), this, e );
}
}
}
diff --git a/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java
index 3843cb90e398..f2944f019b8f 100644
--- a/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java
+++ b/sfx2/qa/complex/sfx2/DocumentMetadataAccess.java
@@ -46,7 +46,6 @@ import com.sun.star.lang.XComponent;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.WrappedTargetRuntimeException;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.StringPair;
@@ -863,28 +862,9 @@ public class DocumentMetadataAccess
// utilities -------------------------------------------------------------
- public void report2(Exception e)
- {
- if (e instanceof WrappedTargetException)
- {
- System.out.println("Cause:");
- Exception cause = (Exception)
- (((WrappedTargetException)e).TargetException);
- System.out.println(cause.toString());
- report2(cause);
- } else if (e instanceof WrappedTargetRuntimeException) {
- System.out.println("Cause:");
- Exception cause = (Exception)
- (((WrappedTargetRuntimeException)e).TargetException);
- System.out.println(cause.toString());
- report2(cause);
- }
- }
-
public void report(Exception e) {
System.out.println("Exception occurred:");
e.printStackTrace(System.err);
- report2(e);
fail();
}
diff --git a/sw/qa/complex/writer/LoadSaveTest.java b/sw/qa/complex/writer/LoadSaveTest.java
index e6027b6a7e94..f617a93d8b42 100644
--- a/sw/qa/complex/writer/LoadSaveTest.java
+++ b/sw/qa/complex/writer/LoadSaveTest.java
@@ -20,8 +20,6 @@ package complex.writer;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
-import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.WrappedTargetRuntimeException;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XComponent;
@@ -165,29 +163,10 @@ public class LoadSaveTest
public void disposing(EventObject Event) { }
}
- void report2(Exception e)
- {
- if (e instanceof WrappedTargetException)
- {
- System.out.println("Cause:");
- Exception cause = (Exception)
- (((WrappedTargetException)e).TargetException);
- System.out.println(cause.toString());
- report2(cause);
- } else if (e instanceof WrappedTargetRuntimeException) {
- System.out.println("Cause:");
- Exception cause = (Exception)
- (((WrappedTargetRuntimeException)e).TargetException);
- System.out.println(cause.toString());
- report2(cause);
- }
- }
-
void report(Exception e) {
System.out.println("Exception occurred:");
System.out.println(e.toString());
e.printStackTrace(System.err);
- report2(e);
// failed();
}
diff --git a/unoxml/qa/complex/unoxml/RDFRepositoryTest.java b/unoxml/qa/complex/unoxml/RDFRepositoryTest.java
index 3b560bdaf2d3..e47d5d3b6e80 100644
--- a/unoxml/qa/complex/unoxml/RDFRepositoryTest.java
+++ b/unoxml/qa/complex/unoxml/RDFRepositoryTest.java
@@ -25,8 +25,6 @@ import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.IllegalArgumentException;
-import com.sun.star.lang.WrappedTargetException;
-import com.sun.star.lang.WrappedTargetRuntimeException;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.Pair;
import com.sun.star.beans.StringPair;
@@ -549,28 +547,9 @@ public class RDFRepositoryTest
// utilities -------------------------------------------------------------
- public void report2(Exception e)
- {
- if (e instanceof WrappedTargetException)
- {
- System.out.println("Cause:");
- Exception cause = (Exception)
- (((WrappedTargetException)e).TargetException);
- System.out.println(cause.toString());
- report2(cause);
- } else if (e instanceof WrappedTargetRuntimeException) {
- System.out.println("Cause:");
- Exception cause = (Exception)
- (((WrappedTargetRuntimeException)e).TargetException);
- System.out.println(cause.toString());
- report2(cause);
- }
- }
-
public void report(Exception e) {
System.out.println("Exception occurred:");
e.printStackTrace();
- report2(e);
fail();
}