java: when rethrowing exceptions, store the original cause
so that we get a nice complete stacktrace when it hits the final handler Change-Id: Iec4fcc15a2a25c55f591b5e069dce3d010197a90
This commit is contained in:
@@ -16,16 +16,16 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
package com.sun.star.script.framework.container;
|
||||
|
||||
import com.sun.star.script.framework.log.*;
|
||||
import com.sun.star.script.framework.io.*;
|
||||
import com.sun.star.script.framework.provider.PathUtils;
|
||||
|
||||
import com.sun.star.container.*;
|
||||
import com.sun.star.uno.Type;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
|
||||
import com.sun.star.ucb.XSimpleFileAccess;
|
||||
import com.sun.star.ucb.XSimpleFileAccess2;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Parcel implements XNameContainer
|
||||
@@ -82,7 +82,7 @@ public class Parcel implements XNameContainer
|
||||
// catch unknown or un-checked exceptions
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
if ( thescript == null )
|
||||
{
|
||||
@@ -199,7 +199,7 @@ public class Parcel implements XNameContainer
|
||||
catch ( Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("Failed to insert entry " + aName + ": " + e.getMessage());
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public class Parcel implements XNameContainer
|
||||
catch ( Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("** Parcel.removeByName Exception: " + e );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,19 +21,19 @@ package com.sun.star.script.framework.container;
|
||||
import com.sun.star.script.framework.log.*;
|
||||
import com.sun.star.script.framework.io.*;
|
||||
import com.sun.star.script.framework.provider.PathUtils;
|
||||
|
||||
import com.sun.star.container.*;
|
||||
import com.sun.star.uno.Type;
|
||||
import com.sun.star.lang.*;
|
||||
import com.sun.star.io.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.star.ucb.XSimpleFileAccess;
|
||||
import com.sun.star.ucb.XSimpleFileAccess2;
|
||||
import com.sun.star.lang.XMultiComponentFactory;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
|
||||
import com.sun.star.uri.XUriReference;
|
||||
import com.sun.star.uri.XUriReferenceFactory;
|
||||
import com.sun.star.uri.XVndSunStarScriptUrl;
|
||||
@@ -316,7 +316,7 @@ public class ParcelContainer implements XNameAccess
|
||||
}
|
||||
catch ( Exception e)
|
||||
{
|
||||
throw new WrappedTargetException( e.toString() );
|
||||
throw new WrappedTargetException(e);
|
||||
}
|
||||
if ( parcel == null )
|
||||
{
|
||||
@@ -401,13 +401,13 @@ public class ParcelContainer implements XNameAccess
|
||||
{
|
||||
LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for " + getParcelContainerDir() );
|
||||
LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e) );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
catch ( com.sun.star.uno.Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("ParcelContainer.loadParcels caught exception processing folders for " + getParcelContainerDir() );
|
||||
LogUtils.DEBUG("TRACE: " + LogUtils.getTrace(e) );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ public class ParcelContainer implements XNameAccess
|
||||
{
|
||||
|
||||
LogUtils.DEBUG("createParcel() Exception while attempting to create = " + name );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -505,18 +505,18 @@ public class ParcelContainer implements XNameAccess
|
||||
{
|
||||
|
||||
LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " + parcelDescUrl + e );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
catch ( java.io.IOException e )
|
||||
{
|
||||
LogUtils.DEBUG("ParcelContainer.loadParcel() caught IOException while accessing " + parcelDescUrl + ": " + e );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
catch ( com.sun.star.uno.Exception e )
|
||||
{
|
||||
|
||||
LogUtils.DEBUG("loadParcel() Exception while accessing filesystem url = " + parcelDescUrl + e );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
|
||||
finally
|
||||
@@ -562,7 +562,7 @@ public class ParcelContainer implements XNameAccess
|
||||
if (!m_xSFA.isFolder( oldParcelDirUrl ) )
|
||||
{
|
||||
Exception e = new com.sun.star.io.IOException("Invalid Parcel directory: " + oldName );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
LogUtils.DEBUG(" ** ParcelContainer Renaming folder " + oldParcelDirUrl + " to " + newParcelDirUrl );
|
||||
m_xSFA.move( oldParcelDirUrl, newParcelDirUrl );
|
||||
@@ -570,12 +570,12 @@ public class ParcelContainer implements XNameAccess
|
||||
catch ( com.sun.star.ucb.CommandAbortedException ce )
|
||||
{
|
||||
LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + ce );
|
||||
throw new com.sun.star.lang.WrappedTargetException( ce.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(ce);
|
||||
}
|
||||
catch ( com.sun.star.uno.Exception e )
|
||||
{
|
||||
LogUtils.DEBUG(" ** ParcelContainer Renaming failed with " + e );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
|
||||
p.rename( newName );
|
||||
@@ -609,7 +609,7 @@ public class ParcelContainer implements XNameAccess
|
||||
catch( Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("Error deleteing parcel " + name );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString() );
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
|
||||
return parcels.remove( p );
|
||||
@@ -641,12 +641,12 @@ public ParsedScriptUri parseScriptUri( String scriptURI ) throws com.sun.star.l
|
||||
catch( com.sun.star.uno.Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("Problems parsing URL:" + e.toString() );
|
||||
throw new com.sun.star.lang.IllegalArgumentException( "Problems parsing URL reason: " + e.toString() );
|
||||
throw new com.sun.star.lang.IllegalArgumentException(e, "Problems parsing URL");
|
||||
}
|
||||
if ( xFac == null )
|
||||
{
|
||||
LogUtils.DEBUG("Failed to create UrlReference factory");
|
||||
throw new com.sun.star.lang.IllegalArgumentException( "Failed to create UrlReference factory for url " + scriptURI );
|
||||
throw new com.sun.star.lang.IllegalArgumentException( "Failed to create UrlReference factory for url " + scriptURI );
|
||||
}
|
||||
|
||||
XUriReference uriRef = xFac.parse( scriptURI );
|
||||
@@ -655,7 +655,7 @@ public ParsedScriptUri parseScriptUri( String scriptURI ) throws com.sun.star.l
|
||||
if ( sfUri == null )
|
||||
{
|
||||
LogUtils.DEBUG("Failed to parse url");
|
||||
throw new com.sun.star.lang.IllegalArgumentException( "Failed to parse url " + scriptURI );
|
||||
throw new com.sun.star.lang.IllegalArgumentException( "Failed to parse url " + scriptURI );
|
||||
}
|
||||
|
||||
ParsedScriptUri parsedUri = new ParsedScriptUri();
|
||||
|
@@ -28,12 +28,9 @@ import java.io.OutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
|
||||
import com.sun.star.io.XOutputStream;
|
||||
import com.sun.star.io.XTruncate;
|
||||
|
||||
import com.sun.star.deployment.XPackage;
|
||||
|
||||
public class UnoPkgContainer extends ParcelContainer
|
||||
@@ -226,7 +223,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
{
|
||||
LogUtils.DEBUG("getUnoPackagesDB() caught Exception: " + e );
|
||||
LogUtils.DEBUG( LogUtils.getTrace( e ) );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString());
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -280,7 +277,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
catch( Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("In writeUnoPackageDB() Exception: " + e );
|
||||
throw new com.sun.star.lang.WrappedTargetException( e.toString());
|
||||
throw new com.sun.star.lang.WrappedTargetException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -317,7 +314,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
}
|
||||
catch (com.sun.star.deployment.ExtensionRemovedException e)
|
||||
{
|
||||
throw new com.sun.star.lang.WrappedTargetException(e.toString(), this, e);
|
||||
throw new com.sun.star.lang.WrappedTargetException(e.getMessage(), this, e);
|
||||
}
|
||||
|
||||
processUnoPackage( uri, language );
|
||||
@@ -331,7 +328,7 @@ public class UnoPkgContainer extends ParcelContainer
|
||||
}
|
||||
catch ( java.io.IOException ioe )
|
||||
{
|
||||
throw new com.sun.star.lang.WrappedTargetException( ioe.toString());
|
||||
throw new com.sun.star.lang.WrappedTargetException(ioe);
|
||||
}
|
||||
}
|
||||
db.addPackage( language, uri );
|
||||
|
@@ -126,12 +126,12 @@ public class UCBStreamHandler extends URLStreamHandler {
|
||||
catch ( com.sun.star.ucb.CommandAbortedException cae )
|
||||
{
|
||||
LogUtils.DEBUG("caught exception: " + cae.toString() + " getting writable stream from " + url );
|
||||
throw new IOException( cae.toString() );
|
||||
throw new IOException(cae);
|
||||
}
|
||||
catch ( com.sun.star.uno.Exception e )
|
||||
{
|
||||
LogUtils.DEBUG("caught unknown exception: " + e.toString() + " getting writable stream from " + url );
|
||||
throw new IOException( e.toString() );
|
||||
throw new IOException(e);
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
@@ -18,9 +18,10 @@
|
||||
|
||||
package com.sun.star.script.framework.io;
|
||||
|
||||
import com.sun.star.io.XInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.sun.star.io.XInputStream;
|
||||
|
||||
public class XInputStreamImpl implements XInputStream
|
||||
{
|
||||
@@ -47,11 +48,11 @@ public class XInputStreamImpl implements XInputStream
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new com.sun.star.io.IOException( e.toString() );
|
||||
throw new com.sun.star.io.IOException(e);
|
||||
}
|
||||
catch ( IndexOutOfBoundsException aie )
|
||||
{
|
||||
throw new com.sun.star.io.BufferSizeExceededException( aie.toString() );
|
||||
throw new com.sun.star.io.BufferSizeExceededException(aie);
|
||||
}
|
||||
return totalBytesRead;
|
||||
}
|
||||
@@ -76,7 +77,7 @@ public class XInputStreamImpl implements XInputStream
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new com.sun.star.io.IOException( e.toString() );
|
||||
throw new com.sun.star.io.IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ public class XInputStreamImpl implements XInputStream
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new com.sun.star.io.IOException( e.toString() );
|
||||
throw new com.sun.star.io.IOException(e);
|
||||
}
|
||||
return bytesAvail;
|
||||
}
|
||||
@@ -102,7 +103,7 @@ public class XInputStreamImpl implements XInputStream
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new com.sun.star.io.IOException( e.toString() );
|
||||
throw new com.sun.star.io.IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user