Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3dccdb3a2ab682d8b26d10cd6f96343768e23655 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*******************************************************************************
 * Copyright (c) 2007, 2008 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.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(IStatus status : statuses) {
						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