From: Marc-Andre Laperle Date: Fri, 26 Aug 2016 03:19:49 +0000 (-0400) Subject: tmf: Log the exception when error occurs while opening a trace X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=c05500117df102b059a2932b5b75369c5039f389 tmf: Log the exception when error occurs while opening a trace 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 Reviewed-on: https://git.eclipse.org/r/79792 Reviewed-by: Hudson CI --- diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java index 6281b56a57..cb644509be 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfOpenTraceHelper.java @@ -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; } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TraceUtils.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TraceUtils.java index 23484f460c..59bb7ef1b3 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TraceUtils.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TraceUtils.java @@ -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); } });