Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java')
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java
new file mode 100644
index 00000000000..6802f700941
--- /dev/null
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineUtil.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.templateengine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public class TemplateEngineUtil {
+
+ public static void log(Throwable t) {
+ if (t == null) {
+ return;
+ }
+ if (t instanceof InvocationTargetException) {
+ t = ((InvocationTargetException) t).getTargetException();
+ }
+ if (t instanceof CoreException) {
+ ResourcesPlugin.getPlugin().getLog().log(((CoreException) t).getStatus());
+ } if (t instanceof ProcessFailureException) {
+ do {
+ List/*<IStatus>*/ statuses = ((ProcessFailureException) t).getStatuses();
+ if (statuses != null) {
+ for(Iterator i = statuses.iterator(); i.hasNext(); ) {
+ IStatus status = (IStatus) i.next();
+ ResourcesPlugin.getPlugin().getLog().log(status);
+ }
+ }
+ t = t.getCause();
+ } while (t != null && t instanceof ProcessFailureException);
+ } else {
+ ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, t.getMessage() == null ? t.toString() : t.getMessage() , t));
+ }
+ }
+
+}

Back to the top