Skip to content

Commit cc56d7c

Browse files
committed
Improve error lggging around TerminalServiceRunnable
Prior to this change there were many exceptions that would simply disappear inside the CompletableFuture since no error handling was implemented. This commit adds basic error handling of logging failed futures.
1 parent 2a99dca commit cc56d7c

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherHandler.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.eclipse.core.commands.AbstractHandler;
2020
import org.eclipse.core.commands.ExecutionEvent;
2121
import org.eclipse.core.commands.ExecutionException;
22+
import org.eclipse.core.runtime.ILog;
2223
import org.eclipse.core.runtime.IPath;
2324
import org.eclipse.jface.viewers.ISelection;
2425
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -72,11 +73,11 @@ private void executeDelegate(ISelection selection, ILauncherDelegate delegate) t
7273
Map<String, Object> properties = new HashMap<>();
7374
properties.put(ITerminalsConnectorConstants.PROP_DELEGATE_ID, delegate.getId());
7475
properties.put(ITerminalsConnectorConstants.PROP_SELECTION, selection);
75-
try {
76-
delegate.execute(properties);
77-
} catch (Exception e) {
78-
throw new ExecutionException(e.getMessage(), e);
79-
}
76+
delegate.execute(properties).whenComplete((r, e) -> {
77+
if (e != null) {
78+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
79+
}
80+
});
8081
}
8182

8283
}

terminal/bundles/org.eclipse.terminal.view.ui/src/org/eclipse/terminal/view/ui/internal/TerminalService.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.eclipse.core.runtime.Assert;
2222
import org.eclipse.core.runtime.CoreException;
23-
import org.eclipse.core.runtime.ILog;
2423
import org.eclipse.core.runtime.ISafeRunnable;
2524
import org.eclipse.core.runtime.ListenerList;
2625
import org.eclipse.core.runtime.SafeRunner;
@@ -261,11 +260,7 @@ public void run(TerminalViewId tvid, String title, ITerminalConnector connector,
261260
} else {
262261
// First, restore the view. This opens consoles from the memento
263262
fRestoringView = true;
264-
try {
265-
consoleViewManager.showConsoleView(tvid);
266-
} catch (CoreException e) {
267-
ILog.get().log(e.getStatus());
268-
}
263+
consoleViewManager.showConsoleView(tvid);
269264
fRestoringView = false;
270265
doRun(tvid, title, connector, data);
271266
}
@@ -306,15 +301,12 @@ private void doRun(TerminalViewId tvid, String title, ITerminalConnector connect
306301
@Override
307302
public CompletableFuture<?> closeConsole(Map<String, Object> properties) {
308303
Assert.isNotNull(properties);
309-
return executeServiceOperation(properties,
310-
(tvid, title, connector, data) -> consoleViewManager.closeConsole(tvid, title, connector, data));
304+
return executeServiceOperation(properties, consoleViewManager::closeConsole);
311305
}
312306

313307
@Override
314308
public CompletableFuture<?> terminateConsole(Map<String, Object> properties) {
315309
Assert.isNotNull(properties);
316-
317-
return executeServiceOperation(properties,
318-
(tvid, title, connector, data) -> consoleViewManager.terminateConsole(tvid, title, connector, data));
310+
return executeServiceOperation(properties, consoleViewManager::terminateConsole);
319311
}
320312
}

terminal/bundles/org.eclipse.terminal.view.ui/src/org/eclipse/terminal/view/ui/internal/handler/LaunchTerminalCommandHandler.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.eclipse.core.commands.ExecutionEvent;
2424
import org.eclipse.core.commands.ExecutionException;
2525
import org.eclipse.core.runtime.CoreException;
26+
import org.eclipse.core.runtime.ILog;
2627
import org.eclipse.jface.viewers.ISelection;
2728
import org.eclipse.jface.viewers.IStructuredSelection;
2829
import org.eclipse.jface.window.Window;
@@ -172,11 +173,11 @@ private void executeDelegate(ISelection selection, ILauncherDelegate delegate) t
172173
}
173174

174175
private void executeDelegate(Map<String, Object> properties, ILauncherDelegate delegate) throws ExecutionException {
175-
try {
176-
delegate.execute(properties);
177-
} catch (Exception e) {
178-
throw new ExecutionException(e.getMessage(), e);
179-
}
176+
delegate.execute(properties).whenComplete((r, e) -> {
177+
if (e != null) {
178+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
179+
}
180+
});
180181
}
181182

182183
}

terminal/bundles/org.eclipse.terminal.view.ui/src/org/eclipse/terminal/view/ui/internal/local/showin/DynamicContributionItems.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public void run() {
128128
}
129129
properties.put(ITerminalsConnectorConstants.PROP_TRANSLATE_BACKSLASHES_ON_PASTE,
130130
Boolean.valueOf(translate));
131-
try {
132-
delegate.execute(properties);
133-
} catch (Exception e) {
134-
ILog.get().error(e.getMessage(), e);
135-
}
131+
delegate.execute(properties).whenComplete((r, e) -> {
132+
if (e != null) {
133+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
134+
}
135+
});
136136
}
137137
};
138138

terminal/bundles/org.eclipse.terminal.view.ui/src/org/eclipse/terminal/view/ui/internal/view/TerminalsViewMementoHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ private Optional<ILauncherDelegate> findDelegate(Map<String, Object> properties)
200200
}
201201

202202
private void executeDelegate(Map<String, Object> properties, ILauncherDelegate delegate) {
203-
try {
204-
delegate.execute(properties);
205-
} catch (Exception e) {
206-
ILog.get().error(e.getMessage(), e);
207-
}
203+
delegate.execute(properties).whenComplete((r, e) -> {
204+
if (e != null) {
205+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
206+
}
207+
});
208208
}
209209

210210
private Optional<IMementoHandler> mementoHandler(ILauncherDelegate delegate) {

0 commit comments

Comments
 (0)