diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 5587cf3c31d..1776172f432 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.CDOM; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.parser.IScannerInfoProvider; @@ -257,11 +258,16 @@ public class CCorePlugin extends Plugin { } public static void log(Throwable e) { - if ( e instanceof CoreException ) { - log(((CoreException)e).getStatus()); - } else { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$ + log("Error", e); //$NON-NLS-1$ + } + + public static void log(String message, Throwable e) { + Throwable nestedException; + if (e instanceof CModelException + && (nestedException = ((CModelException)e).getException()) != null) { + e = nestedException; } + log(createStatus(message, e)); } public static IStatus createStatus(String msg) { @@ -273,7 +279,7 @@ public class CCorePlugin extends Plugin { } public static void log(IStatus status) { - ((Plugin) getDefault()).getLog().log(status); + getDefault().getLog().log(status); } // ------ CPlugin diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 59cac78fdb9..e08cf953c08 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -278,12 +278,16 @@ public class CUIPlugin extends AbstractUIPlugin { return fgCPlugin; } - public void log(Throwable e) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$ + public static void log(Throwable e) { + log("Error", e); //$NON-NLS-1$ } - public void log(IStatus status) { - getLog().log(status); + public static void log(String message, Throwable e) { + log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e)); + } + + public static void log(IStatus status) { + getDefault().getLog().log(status); } public void logErrorMessage(String message) { @@ -297,7 +301,7 @@ public class CUIPlugin extends AbstractUIPlugin { */ public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) { if (logError) - getDefault().log(s); + log(s); // if the 'message' resource string and the IStatus' message are the same, // don't show both in the dialog @@ -313,7 +317,7 @@ public class CUIPlugin extends AbstractUIPlugin { */ public static void errorDialog(Shell shell, String title, String message, Throwable t, boolean logError) { if (logError) - getDefault().log(t); + log(t); IStatus status; if (t instanceof CoreException) {