tmf: Log the exception when error occurs while opening a trace
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Fri, 26 Aug 2016 03:19:49 +0000 (23:19 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Fri, 7 Oct 2016 20:32:36 +0000 (16:32 -0400)
If an exception occurs when opening a trace, the exception message
is displayed but the stack is nowhere to be found. By logging the
exception, the stack trace will be available in the log.

Change-Id: I8085cb46a1657747cc2f2be5736e4b17e0b7040f
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/79792
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TraceUtils.java

index 6281b56a57b43a04a36c48732f73757fcbfc1f2a..cb644509be9ec93d8f5e1429cb85c87c606cdf40 100644 (file)
@@ -263,7 +263,7 @@ public class TmfOpenTraceHelper {
             trace.initTrace(traceElement.getResource(), traceElement.getResource().getLocation().toOSString(), traceEvent.getClass(), traceElement.getElementPath(), traceElement.getTraceType());
         } catch (final TmfTraceException e) {
             TraceUtils.displayErrorMsg(NLS.bind(Messages.TmfOpenTraceHelper_OpenElement, traceElement.getTypeName()),
-                    Messages.TmfOpenTraceHelper_InitError + ENDL + ENDL + e);
+                    Messages.TmfOpenTraceHelper_InitError + ENDL + ENDL + e, e);
             trace.dispose();
             return null;
         }
index 23484f460ce9b341ec9eb14befdc01a1c76f7452..59bb7ef1b3a63bf8ec93edfff22448ff9856803c 100644 (file)
@@ -46,11 +46,27 @@ public class TraceUtils {
      *            The error message to display
      */
     public static void displayErrorMsg(final String boxTitle, final String errorMsg) {
+        displayErrorMsg(boxTitle, errorMsg, null);
+    }
+
+    /**
+     * Displays an error message in a box
+     *
+     * @param boxTitle
+     *            The message box title
+     * @param errorMsg
+     *            The error message to display
+     * @param exception
+     *            the exception or null if the error does not originate from an
+     *            exception
+     * @since 2.2
+     */
+    public static void displayErrorMsg(final String boxTitle, final String errorMsg, Throwable exception) {
         Display.getDefault().asyncExec(new Runnable() {
             @Override
             public void run() {
                 final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-                Activator.getDefault().logError(errorMsg);
+                Activator.getDefault().logError(errorMsg, exception);
                 MessageDialog.openError(shell, boxTitle, errorMsg);
             }
         });
This page took 0.026016 seconds and 5 git commands to generate.