Skip to content

Commit 89cba75

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 a05dae8 commit 89cba75

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
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: 1 addition & 6 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;
@@ -260,11 +259,7 @@ public void run(TerminalViewId tvid, String title, ITerminalConnector connector,
260259
} else {
261260
// First, restore the view. This opens consoles from the memento
262261
fRestoringView = true;
263-
try {
264-
consoleViewManager.showConsoleView(tvid);
265-
} catch (CoreException e) {
266-
ILog.get().log(e.getStatus());
267-
}
262+
consoleViewManager.showConsoleView(tvid);
268263
fRestoringView = false;
269264
doRun(tvid, title, connector, data);
270265
}

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)