Kaydet (Commit) 6884ef63 authored tarafından Noel Grandin's avatar Noel Grandin

java: don't catch and then just rethrow an exception

without doing anything else useful

Change-Id: I5803d84d46e0a70e1759f2202e2c2273087f8723
üst 8c9fdc4a
...@@ -134,8 +134,6 @@ public class OptionsEventHandler { ...@@ -134,8 +134,6 @@ public class OptionsEventHandler {
if (sMethod.equals("external_event") ){ if (sMethod.equals("external_event") ){
try { try {
return handleExternalEvent(aWindow, aEventObject); return handleExternalEvent(aWindow, aEventObject);
} catch (com.sun.star.uno.RuntimeException re) {
throw re;
} catch (com.sun.star.uno.Exception e) { } catch (com.sun.star.uno.Exception e) {
throw new WrappedTargetException(sMethod, this, e); throw new WrappedTargetException(sMethod, this, e);
} }
......
...@@ -32,6 +32,7 @@ import com.sun.star.io.XTruncate; ...@@ -32,6 +32,7 @@ import com.sun.star.io.XTruncate;
import com.sun.star.lang.XComponent; import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.lib.util.ExceptionHelper;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
...@@ -109,17 +110,13 @@ public final class OwnEmbeddedObject extends WeakBase ...@@ -109,17 +110,13 @@ public final class OwnEmbeddedObject extends WeakBase
XStorage xOwnStorage = xParentStorage.openStorageElement( aEntryName, com.sun.star.embed.ElementModes.READWRITE ); XStorage xOwnStorage = xParentStorage.openStorageElement( aEntryName, com.sun.star.embed.ElementModes.READWRITE );
SwitchOwnPersistence( xParentStorage, xOwnStorage, aEntryName ); SwitchOwnPersistence( xParentStorage, xOwnStorage, aEntryName );
} }
catch( com.sun.star.uno.RuntimeException e )
{
throw e;
}
catch( com.sun.star.io.IOException e ) catch( com.sun.star.io.IOException e )
{ {
throw e; throw e;
} }
catch( com.sun.star.uno.Exception e ) catch( com.sun.star.uno.Exception e )
{ {
throw new com.sun.star.io.IOException( "Error while switching object storage!" ); throw ExceptionHelper.initCause(new com.sun.star.io.IOException( "Error while switching object storage!" ), e);
} }
} }
} }
...@@ -170,17 +167,13 @@ public final class OwnEmbeddedObject extends WeakBase ...@@ -170,17 +167,13 @@ public final class OwnEmbeddedObject extends WeakBase
xStreamComp.dispose(); xStreamComp.dispose();
} }
catch( com.sun.star.uno.RuntimeException e )
{
throw e;
}
catch( com.sun.star.io.IOException e ) catch( com.sun.star.io.IOException e )
{ {
throw e; throw e;
} }
catch( com.sun.star.uno.Exception e ) catch( com.sun.star.uno.Exception e )
{ {
throw new com.sun.star.io.IOException( "Error while switching object storage!" ); throw ExceptionHelper.initCause(new com.sun.star.io.IOException( "Error while switching object storage!" ), e);
} }
} }
...@@ -266,17 +259,13 @@ public final class OwnEmbeddedObject extends WeakBase ...@@ -266,17 +259,13 @@ public final class OwnEmbeddedObject extends WeakBase
return aResult; return aResult;
} }
catch( com.sun.star.uno.RuntimeException e )
{
throw e;
}
catch( com.sun.star.io.IOException e ) catch( com.sun.star.io.IOException e )
{ {
throw e; throw e;
} }
catch( com.sun.star.uno.Exception e ) catch( com.sun.star.uno.Exception e )
{ {
throw new com.sun.star.io.IOException( "Error while reading one of object streams!" ); throw ExceptionHelper.initCause(new com.sun.star.io.IOException( "Error while reading one of object streams!" ), e);
} }
} }
......
...@@ -218,38 +218,31 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase ...@@ -218,38 +218,31 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
{ {
if ( sMethod.equals( sExternalEvent ) ) if ( sMethod.equals( sExternalEvent ) )
{ {
try String sEvent = AnyConverter.toString( aEventObject );
if ( sEvent != null )
{ {
String sEvent = AnyConverter.toString( aEventObject ); if ( sEvent.equals( sOk ) )
if ( sEvent != null ) {
if ( m_aSettings != null )
m_aSettings.storeConfiguration();
}
else if ( sEvent.equals( sInitialize ) || sEvent.equals( sBack ) )
{ {
if ( sEvent.equals( sOk ) ) if ( sEvent.equals( sInitialize ) )
{ {
if ( m_aSettings != null ) m_xDialog = UnoRuntime.queryInterface( XDialog.class, xWindow );
m_aSettings.storeConfiguration(); m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog );
m_aSettings = Settings.getSettings( m_xContext );
m_aSettings.loadConfiguration(); // throw away all the noncommited changes
InitStrings();
} }
else if ( sEvent.equals( sInitialize ) || sEvent.equals( sBack ) ) else if ( m_aSettings != null )
{ m_aSettings.loadConfiguration(); // throw away all the noncommited changes
if ( sEvent.equals( sInitialize ) )
{
m_xDialog = UnoRuntime.queryInterface( XDialog.class, xWindow );
m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog );
m_aSettings = Settings.getSettings( m_xContext );
m_aSettings.loadConfiguration(); // throw away all the noncommited changes
InitStrings();
}
else if ( m_aSettings != null )
m_aSettings.loadConfiguration(); // throw away all the noncommited changes
RefreshView(); RefreshView();
CheckButtonState(); CheckButtonState();
}
} }
} }
catch ( com.sun.star.uno.RuntimeException r )
{
throw r;
}
} }
else if ( sMethod.equals( sAdd ) ) else if ( sMethod.equals( sAdd ) )
{ {
......
...@@ -917,16 +917,9 @@ public class TestComponent { ...@@ -917,16 +917,9 @@ public class TestComponent {
public int getRuntimeException() public int getRuntimeException()
throws com.sun.star.uno.RuntimeException throws com.sun.star.uno.RuntimeException
{ {
try dothrow( new com.sun.star.uno.RuntimeException(
{ _string, _xInterface ) );
dothrow( new com.sun.star.uno.RuntimeException( return 0; // dummy
_string, _xInterface ) );
return 0; // dummy
}
catch (com.sun.star.uno.RuntimeException t)
{
throw t;
}
} }
public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException { public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException {
......
...@@ -200,12 +200,6 @@ public class EmbeddedXMLObject extends EmbeddedObject { ...@@ -200,12 +200,6 @@ public class EmbeddedXMLObject extends EmbeddedObject {
} }
} }
catch (SAXException se) {
throw se;
}
catch (IOException ioe) {
throw ioe;
}
catch (ParserConfigurationException pce) { catch (ParserConfigurationException pce) {
throw new SAXException(pce); throw new SAXException(pce);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment