Skip to content

Commit 01adefa

Browse files
sigmaaaAndriiFilippov
authored andcommitted
feat: Improved timeout err msg (#909)
* feat: Improved timeout err msg
1 parent be0bcd5 commit 01adefa

5 files changed

Lines changed: 89 additions & 4 deletions

File tree

bundles/com.espressif.idf.debug.gdbjtag.openocd/plugin.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,14 @@
166166
label="IDF Process Console">
167167
</consoleFactory>
168168
</extension>
169+
<extension
170+
point="org.eclipse.debug.core.statusHandlers">
171+
<statusHandler
172+
class="com.espressif.idf.debug.gdbjtag.openocd.ui.OpenocdStatusHandler"
173+
code="5012"
174+
id="com.espressif.idf.debug.gdbjtag.openocd.openocdStatusHandler"
175+
plugin="com.espressif.idf.debug.gdbjtag.openocd">
176+
</statusHandler>
177+
</extension>
169178

170179
</plugin>

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchConfigurationDelegate.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.eclipse.core.runtime.SubProgressMonitor;
5050
import org.eclipse.core.runtime.jobs.Job;
5151
import org.eclipse.debug.core.DebugException;
52+
import org.eclipse.debug.core.DebugPlugin;
5253
import org.eclipse.debug.core.ILaunch;
5354
import org.eclipse.debug.core.ILaunchConfiguration;
5455
import org.eclipse.debug.core.ILaunchManager;
@@ -446,8 +447,19 @@ else if (sessionType == SessionType.CORE)
446447
}
447448
catch (ExecutionException e1)
448449
{
449-
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
450-
"Error in services launch sequence", e1.getCause())); //$NON-NLS-1$
450+
if (e1.getMessage().contains("Starting OpenOCD timed out.")) //$NON-NLS-1$
451+
{
452+
IStatus status = new Status(IStatus.OK, Activator.PLUGIN_ID, DebugException.REQUEST_FAILED,
453+
"Error in services launch sequence", e1.getCause()); //$NON-NLS-1$
454+
DebugPlugin.getDefault().getStatusHandler(status).handleStatus(status, null);
455+
throw new DebugException(Status.OK_STATUS);
456+
}
457+
else
458+
{
459+
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
460+
"Error in services launch sequence", e1.getCause())); //$NON-NLS-1$
461+
}
462+
451463
}
452464
catch (CancellationException e1)
453465
{

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/Messages.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class Messages
6161
public static String TabMain_Launch_Config;
6262

6363
public static String TabDebugger_SettingTargetJob;
64-
64+
6565
public static String OpenOCDConsole_ErrorGuideMessage;
6666

6767
public static String TabDebugger_noConfigOptions;
@@ -71,6 +71,10 @@ public class Messages
7171
public static String TabDebugger_noTclPort;
7272
public static String TabDebugger_noTelnetPort;
7373

74+
public static String ServerTimeoutErrorDialog_title;
75+
public static String ServerTimeoutErrorDialog_message;
76+
public static String ServerTimeoutErrorDialog_customAreaMessage;
77+
7478
// ------------------------------------------------------------------------
7579

7680
static
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*******************************************************************************
2+
* Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
3+
* Use is subject to license terms.
4+
*******************************************************************************/
5+
package com.espressif.idf.debug.gdbjtag.openocd.ui;
6+
7+
import org.eclipse.core.runtime.CoreException;
8+
import org.eclipse.core.runtime.IStatus;
9+
import org.eclipse.debug.core.IStatusHandler;
10+
import org.eclipse.jface.dialogs.IDialogConstants;
11+
import org.eclipse.jface.dialogs.MessageDialog;
12+
import org.eclipse.swt.SWT;
13+
import org.eclipse.swt.events.SelectionAdapter;
14+
import org.eclipse.swt.events.SelectionEvent;
15+
import org.eclipse.swt.widgets.Composite;
16+
import org.eclipse.swt.widgets.Control;
17+
import org.eclipse.swt.widgets.Display;
18+
import org.eclipse.swt.widgets.Link;
19+
import org.eclipse.ui.dialogs.PreferencesUtil;
20+
21+
public class OpenocdStatusHandler implements IStatusHandler
22+
{
23+
private static final String ESPRESSIF_PREFERENCES_MAINPAGE_ID = "com.espressif.idf.ui.preferences.mainpage"; //$NON-NLS-1$
24+
25+
public Object handleStatus(IStatus status, Object source) throws CoreException
26+
{
27+
Display.getDefault().asyncExec(() -> {
28+
MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(),
29+
Messages.ServerTimeoutErrorDialog_title, null, Messages.ServerTimeoutErrorDialog_message,
30+
MessageDialog.ERROR, 0, IDialogConstants.OK_LABEL)
31+
{
32+
@Override
33+
public Control createCustomArea(Composite parent)
34+
{
35+
Link link = new Link(parent, SWT.WRAP);
36+
link.setText(Messages.ServerTimeoutErrorDialog_customAreaMessage);
37+
link.addSelectionListener(new SelectionAdapter()
38+
{
39+
@Override
40+
public void widgetSelected(SelectionEvent e)
41+
{
42+
PreferencesUtil.createPreferenceDialogOn(parent.getShell(),
43+
ESPRESSIF_PREFERENCES_MAINPAGE_ID, null, null).open();
44+
}
45+
});
46+
return link;
47+
}
48+
49+
};
50+
dialog.open();
51+
});
52+
return null;
53+
}
54+
55+
}

bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/ui/messages.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,9 @@ TabMain_Launch_Config=Launch Configuration:
410410

411411

412412
## Console Messages ##
413-
OpenOCDConsole_ErrorGuideMessage=Please refer to the troubleshooting guide below to identify the problem.
413+
OpenOCDConsole_ErrorGuideMessage=Please refer to the troubleshooting guide below to identify the problem.
414+
415+
## Timeout Exception Dialog ##
416+
ServerTimeoutErrorDialog_customAreaMessage=To increase timeout time visit <a>the Espressif Preference Page</a>.
417+
ServerTimeoutErrorDialog_message=Starting OpenOCD timed out. Try to increase the `GDB server launch timeout`
418+
ServerTimeoutErrorDialog_title=Problem Occurred

0 commit comments

Comments
 (0)