Skip to content

Commit edb38ea

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 edb38ea

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,14 @@ public void run() {
129129
properties.put(ITerminalsConnectorConstants.PROP_TRANSLATE_BACKSLASHES_ON_PASTE,
130130
Boolean.valueOf(translate));
131131
try {
132-
delegate.execute(properties);
132+
delegate.execute(properties).whenComplete((r, e) -> {
133+
if (e != null) {
134+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
135+
}
136+
});
133137
} catch (Exception e) {
134-
ILog.get().error(e.getMessage(), e);
138+
// This wraps any synchronous exceptions - asynchronous exceptions are logged in the whenComplete above
139+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
135140
}
136141
}
137142
};

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,14 @@ private Optional<ILauncherDelegate> findDelegate(Map<String, Object> properties)
201201

202202
private void executeDelegate(Map<String, Object> properties, ILauncherDelegate delegate) {
203203
try {
204-
delegate.execute(properties);
204+
delegate.execute(properties).whenComplete((r, e) -> {
205+
if (e != null) {
206+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
207+
}
208+
});
205209
} catch (Exception e) {
206-
ILog.get().error(e.getMessage(), e);
210+
// This wraps any synchronous exceptions - asynchronous exceptions are logged in the whenComplete above
211+
ILog.get().error("Error occurred while running delegate to open console", e); //$NON-NLS-1$
207212
}
208213
}
209214

0 commit comments

Comments
 (0)