Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 03dc87000e0a7a09f21b86bf557a5307ce29d061 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*******************************************************************************
 * Copyright (c) 2008 Versant Corp.
 * 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:
 *     Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
 ******************************************************************************/

package org.eclipse.ecf.core.util;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.internal.core.identity.Activator;

public class ECFRuntimeException extends RuntimeException {

	private static final long serialVersionUID = 456677468837349011L;
	/** Status object. */
	private IStatus status;

	public ECFRuntimeException() {
		super();
	}

	/**
	 * @param message
	 *            message associated with exception
	 */
	public ECFRuntimeException(String message) {
		this(message, null);
	}

	/**
	 * @param cause
	 *            the cause of the new exception
	 */
	public ECFRuntimeException(Throwable cause) {
		this(cause.getMessage(), cause);
	}

	/**
	 * @param message
	 * @param cause
	 */
	public ECFRuntimeException(String message, Throwable cause) {
		this(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, ((message == null) ? "" : message), cause)); //$NON-NLS-1$
	}

	/**
	 * Creates a new exception with the given status object.  The message
	 * of the given status is used as the exception message.
	 *
	 * @param status the status object to be associated with this exception
	 */
	public ECFRuntimeException(IStatus status) {
		super(status.getMessage());
		this.status = status;
	}

	/**
	 * Returns the status object for this exception.
	 * <p>
	 *   <b>IMPORTANT:</b><br>
	 *   The result must NOT be used to log a <code>CoreException</code>
	 *   (e.g., using <code>yourPlugin.getLog().log(status);</code>),
	 *   since that code pattern hides the original stacktrace.
	 *   Instead, create a new {@link Status} with your plug-in ID and
	 *   this <code>CoreException</code>, and log that new status.
	 * </p>
	 *
	 * @return a status object
	 */
	public IStatus getStatus() {
		return status;
	}
}

Back to the top