1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 04:25:21 +02:00

[270777][cleanup] Improve try..catch construct

This commit is contained in:
Martin Oberhuber 2009-08-10 13:55:32 +00:00
parent 654cf929b5
commit a941b54180

View file

@ -287,20 +287,19 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
_connectorServicePool.waitUntilNotContained(connectorService); _connectorServicePool.waitUntilNotContained(connectorService);
} }
else { else {
final Display dis = Display.getDefault();
_connectorServicePool.add(connectorService); _connectorServicePool.add(connectorService);
Display dis = Display.getDefault();
PromptForPassword prompter = new PromptForPassword(ss);
dis.syncExec(prompter);
if (prompter.isCancelled()) {
SystemMessage cancelledMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED);
SystemMessageObject cancelledMessageObject = new SystemMessageObject(cancelledMessage, ISystemMessageObject.MSGTYPE_CANCEL, _remoteObject);
_collector.add(cancelledMessageObject, monitor);
_connectorServicePool.remove(connectorService);
throw new InterruptedException();
}
try try
{ {
PromptForPassword prompter = new PromptForPassword(ss);
dis.syncExec(prompter);
if (prompter.isCancelled()) {
SystemMessage cancelledMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED);
SystemMessageObject cancelledMessageObject = new SystemMessageObject(cancelledMessage, ISystemMessageObject.MSGTYPE_CANCEL,
_remoteObject);
_collector.add(cancelledMessageObject, monitor);
throw new InterruptedException();
}
connectorService.connect(monitor); connectorService.connect(monitor);
if (_exc != null) if (_exc != null)
{ {
@ -310,13 +309,11 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
catch (InvocationTargetException exc) catch (InvocationTargetException exc)
{ {
showOperationErrorMessage(null, exc, ss); showOperationErrorMessage(null, exc, ss);
_connectorServicePool.remove(connectorService); return false;
return false;
} }
catch (Exception e) catch (Exception e)
{ {
showOperationErrorMessage(null, e, ss); showOperationErrorMessage(null, e, ss);
_connectorServicePool.remove(connectorService);
return false; return false;
} }
finally { finally {
@ -470,7 +467,9 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW
{ {
String excMsg = exc.getMessage(); String excMsg = exc.getMessage();
if ((excMsg == null) || (excMsg.length()==0)) if ((excMsg == null) || (excMsg.length()==0))
excMsg = "Exception " + exc.getClass().getName(); //$NON-NLS-1$ exc.getClass().getName();
else
excMsg = exc.getClass().getName() + ": " + excMsg; //$NON-NLS-1$
sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED); sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED);
sysMsg.makeSubstitution(excMsg); sysMsg.makeSubstitution(excMsg);