diff options
author | Noel Grandin <noel@peralex.com> | 2014-10-16 12:19:14 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2014-10-16 12:27:15 +0200 |
commit | 9341bf3dc38b2cc117ffbe12ff057511ed6e046d (patch) | |
tree | 3a54c1764eb0e3106695292a737944507d3b4fb6 /jurt | |
parent | b2f69f626409442d1f0ca5049b946946ce9b01d8 (diff) |
java: when rethrowing, store the original exception
Change-Id: I34ce000c48d2d79bfec854c8dd55d12f2bee29c7
Diffstat (limited to 'jurt')
6 files changed, 26 insertions, 30 deletions
diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java index 8244d43c326c..03b1a7fbd205 100644 --- a/jurt/com/sun/star/comp/loader/JavaLoader.java +++ b/jurt/com/sun/star/comp/loader/JavaLoader.java @@ -121,10 +121,10 @@ public class JavaLoader implements XImplementationLoader, } return ret; } catch (com.sun.star.uno.Exception exc) { - throw new com.sun.star.uno.RuntimeException( + throw new com.sun.star.uno.RuntimeException(exc, exc.getMessage(), this ); } catch (java.lang.Exception exc) { - throw new com.sun.star.uno.RuntimeException( + throw new com.sun.star.uno.RuntimeException(exc, exc.getMessage(), this ); } } @@ -174,7 +174,7 @@ public class JavaLoader implements XImplementationLoader, multiServiceFactory = (XMultiServiceFactory) AnyConverter.toObject( new Type(XMultiServiceFactory.class), args[0]); } catch (ClassCastException castEx) { - throw new com.sun.star.lang.IllegalArgumentException( + throw new com.sun.star.lang.IllegalArgumentException(castEx, "The argument must be an instance of XMultiServiceFactory"); } } @@ -330,21 +330,21 @@ public class JavaLoader implements XImplementationLoader, returnObject = oRet; } } catch ( NoSuchMethodException e) { - throw new CannotActivateFactoryException("Can not activate the factory for " - + implementationName + " because " + e.toString() ); + throw new CannotActivateFactoryException(e, "Can not activate the factory for " + + implementationName); } catch ( SecurityException e) { - throw new CannotActivateFactoryException("Can not activate the factory for " - + implementationName + " because " + e.toString() ); + throw new CannotActivateFactoryException(e, "Can not activate the factory for " + + implementationName); } catch ( IllegalAccessException e ) { - throw new CannotActivateFactoryException("Can not activate the factory for " - + implementationName + " because " + e.toString() ); + throw new CannotActivateFactoryException(e, "Can not activate the factory for " + + implementationName); } catch ( IllegalArgumentException e ) { - throw new CannotActivateFactoryException("Can not activate the factory for " - + implementationName + " because " + e.toString() ); + throw new CannotActivateFactoryException(e, "Can not activate the factory for " + + implementationName); } catch ( InvocationTargetException e ) { - throw new CannotActivateFactoryException("Can not activate the factory for " - + implementationName + " because " + e.getCause().toString() ); + throw new CannotActivateFactoryException(e, "Can not activate the factory for " + + implementationName); } return returnObject; diff --git a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java index 60cf351162b9..5a7e91c77fe5 100644 --- a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java +++ b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java @@ -87,7 +87,7 @@ public class UrlResolver { xBridgeFactory = UnoRuntime.queryInterface(XBridgeFactory.class, _xMultiServiceFactory.createInstance("com.sun.star.bridge.BridgeFactory")); } catch (com.sun.star.uno.Exception e) { - throw new com.sun.star.uno.RuntimeException(e.getMessage()); + throw new com.sun.star.uno.RuntimeException(e); } XBridge xBridge = xBridgeFactory.getBridge(conDcp + ";" + protDcp); @@ -96,7 +96,7 @@ public class UrlResolver { try { connector = _xMultiServiceFactory.createInstance("com.sun.star.connection.Connector"); } catch (com.sun.star.uno.Exception e) { - throw new com.sun.star.uno.RuntimeException(e.getMessage()); + throw new com.sun.star.uno.RuntimeException(e); } XConnector connector_xConnector = UnoRuntime.queryInterface(XConnector.class, connector); @@ -106,7 +106,7 @@ public class UrlResolver { try { xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, null); } catch (com.sun.star.bridge.BridgeExistsException e) { - throw new com.sun.star.uno.RuntimeException(e.getMessage()); + throw new com.sun.star.uno.RuntimeException(e); } } rootObject = xBridge.getInstance(rootOid); diff --git a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java index 2552c9b9689b..44016075b42b 100644 --- a/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java +++ b/jurt/com/sun/star/lib/connections/pipe/PipeConnection.java @@ -84,12 +84,10 @@ public class PipeConnection implements XConnection, XConnectionBroadcaster { // create the pipe try { createJNI( aPipeName ); - } catch ( NullPointerException aNPE ) { - throw new IOException( aNPE.getMessage() ); - } catch ( com.sun.star.io.IOException aIOE ) { - throw new IOException( aIOE.getMessage() ); - } catch ( java.lang.Exception aE ) { - throw new IOException( aE.getMessage() ); + } catch ( java.lang.Exception ex1 ) { + IOException ex2 = new IOException(); + ex2.initCause(ex1); + throw ex2; } } diff --git a/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java b/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java index 95c064ed58a9..d70138457ced 100644 --- a/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java +++ b/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java @@ -109,7 +109,7 @@ public final class pipeConnector implements XConnector { bConnected = true; return xConn; } catch ( java.io.IOException e ) { - throw new NoConnectException(); + throw new NoConnectException(e); } } diff --git a/jurt/com/sun/star/lib/connections/socket/ConnectionDescriptor.java b/jurt/com/sun/star/lib/connections/socket/ConnectionDescriptor.java index aec6a638e095..4cd8e433c056 100644 --- a/jurt/com/sun/star/lib/connections/socket/ConnectionDescriptor.java +++ b/jurt/com/sun/star/lib/connections/socket/ConnectionDescriptor.java @@ -45,8 +45,7 @@ final class ConnectionDescriptor { try { port = Integer.parseInt(value); } catch (NumberFormatException e) { - throw new com.sun.star.lang.IllegalArgumentException( - e.toString()); + throw new com.sun.star.lang.IllegalArgumentException(e); } if (port < 0 || port > 65535) { throw new com.sun.star.lang.IllegalArgumentException( @@ -57,8 +56,7 @@ final class ConnectionDescriptor { try { backlog = Integer.parseInt(value); } catch (NumberFormatException e) { - throw new com.sun.star.lang.IllegalArgumentException( - e.toString()); + throw new com.sun.star.lang.IllegalArgumentException(e); } } else if (key.equalsIgnoreCase("tcpnodelay")) { if (value.equals("0")) { diff --git a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java index 6f2a548afb2c..c0a94d62e735 100644 --- a/jurt/com/sun/star/lib/connections/socket/SocketConnection.java +++ b/jurt/com/sun/star/lib/connections/socket/SocketConnection.java @@ -173,7 +173,7 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { try { _outputStream.write(aData); } catch(IOException ioException) { - com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString()); + com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException); notifyListeners_error(unoIOException); throw unoIOException; @@ -192,7 +192,7 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { try { _outputStream.flush(); } catch(IOException ioException) { - com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString()); + com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException); notifyListeners_error(unoIOException); throw unoIOException; @@ -209,7 +209,7 @@ public class SocketConnection implements XConnection, XConnectionBroadcaster { try { _socket.close(); } catch(IOException ioException) { - com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException.toString()); + com.sun.star.io.IOException unoIOException = new com.sun.star.io.IOException(ioException); notifyListeners_error(unoIOException); throw unoIOException; |