Package org.eclipse.core.runtime
Class CoreException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- org.eclipse.core.runtime.CoreException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DebugException,ProvisionException,TeamException,ValidateStateException,WorkbenchException
public class CoreException extends Exception
A checked exception representing a failure.Core exceptions contain a status object describing the cause of the exception.
This class can be used without OSGi running.
- See Also:
IStatus, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CoreException(IStatus status)Creates a new exception with the given status object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThrowablegetCause()Returns the cause of this exception, ornullif none.IStatusgetStatus()Returns the status object for this exception.voidprintStackTrace()Prints a stack trace out for the exception, and any nested exception that it may have embedded in its Status object.voidprintStackTrace(PrintStream output)Prints a stack trace out for the exception, and any nested exception that it may have embedded in its Status object.voidprintStackTrace(PrintWriter output)Prints a stack trace out for the exception, and any nested exception that it may have embedded in its Status object.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
-
-
-
-
Constructor Detail
-
CoreException
public CoreException(IStatus status)
Creates a new exception with the given status object. The message of the given status is used as the exception message.- Parameters:
status- the status object to be associated with this exception
-
-
Method Detail
-
getCause
public Throwable getCause()
Returns the cause of this exception, ornullif none.
-
getStatus
public final IStatus getStatus()
Returns the status object for this exception.IMPORTANT:
The result must NOT be used for logging, error reporting, or as a method return value, since that code pattern hides the original stack trace. Instead, create a newStatuswith your plug-in ID and thisCoreException, and use that new status for error reporting or as a method return value. For example, instead of:yourPlugin.getLog().log(exception.getStatus());Use:IStatus result = new Status(exception.getStatus().getSeverity(), pluginId, message, exception); yourPlugin.getLog().log(result);- Returns:
- a status object
-
printStackTrace
public void printStackTrace()
Prints a stack trace out for the exception, and any nested exception that it may have embedded in its Status object.- Overrides:
printStackTracein classThrowable
-
printStackTrace
public void printStackTrace(PrintStream output)
Prints a stack trace out for the exception, and any nested exception that it may have embedded in its Status object.- Overrides:
printStackTracein classThrowable- Parameters:
output- the stream to write to
-
printStackTrace
public void printStackTrace(PrintWriter output)
Prints a stack trace out for the exception, and any nested exception that it may have embedded in its Status object.- Overrides:
printStackTracein classThrowable- Parameters:
output- the stream to write to
-
-