Package org.eclipse.jdt.core
Class JavaModelException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- org.eclipse.core.runtime.CoreException
-
- org.eclipse.jdt.core.JavaModelException
-
- All Implemented Interfaces:
Serializable
public class JavaModelException extends CoreException
A checked exception representing a failure in the Java model. Java model exceptions contain a Java-specific status object describing the cause of the exception.Instances of this class are automatically created by the Java model when problems arise, so there is generally no need for clients to create instances.
- See Also:
IJavaModelStatus,IJavaModelStatusConstants, Serialized Form- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Constructor Summary
Constructors Constructor Description JavaModelException(Throwable e, int code)Creates a Java model exception that wrappers the givenThrowable.JavaModelException(CoreException exception)Creates a Java model exception for the givenCoreException.JavaModelException(IStatus status)Creates a Java model exception for the given status object.JavaModelException(IJavaModelStatus status)Creates a Java model exception for the given Java-specific status object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThrowablegetException()Returns the underlyingThrowablethat caused the failure.IJavaModelStatusgetJavaModelStatus()Returns the Java model status object for this exception.booleanisDoesNotExist()Returns whether this exception indicates that a Java model element does not exist.voidprintStackTrace(PrintStream output)Prints this exception's stack trace to the given print stream.voidprintStackTrace(PrintWriter output)Prints this exception's stack trace to the given print writer.StringtoString()-
Methods inherited from class org.eclipse.core.runtime.CoreException
getCause, getStatus, printStackTrace
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, setStackTrace
-
-
-
-
Constructor Detail
-
JavaModelException
public JavaModelException(Throwable e, int code)
Creates a Java model exception that wrappers the givenThrowable. The exception contains a Java-specific status object with severityIStatus.ERRORand the given status code.- Parameters:
e- theThrowablecode- one of the Java-specific status codes declared inIJavaModelStatusConstants- See Also:
IJavaModelStatusConstants,IStatus.ERROR
-
JavaModelException
public JavaModelException(CoreException exception)
Creates a Java model exception for the givenCoreException. Equivalent toJavaModelException(exception,IJavaModelStatusConstants.CORE_EXCEPTION.- Parameters:
exception- theCoreException
-
JavaModelException
public JavaModelException(IJavaModelStatus status)
Creates a Java model exception for the given Java-specific status object.- Parameters:
status- the Java-specific status object
-
JavaModelException
public JavaModelException(IStatus status)
Creates a Java model exception for the given status object.- Since:
- 3.14
-
-
Method Detail
-
getException
public Throwable getException()
Returns the underlyingThrowablethat caused the failure.- Returns:
- the wrapped
Throwable, ornullif the direct case of the failure was at the Java model layer
-
getJavaModelStatus
public IJavaModelStatus getJavaModelStatus()
Returns the Java model status object for this exception. Equivalent to(IJavaModelStatus) getStatus().- Returns:
- a status object
-
isDoesNotExist
public boolean isDoesNotExist()
Returns whether this exception indicates that a Java model element does not exist. Such exceptions have a status with a code ofIJavaModelStatusConstants.ELEMENT_DOES_NOT_EXISTorIJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH. This is a convenience method.- Returns:
trueif this exception indicates that a Java model element does not exist- See Also:
IJavaModelStatus.isDoesNotExist(),IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST,IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH
-
printStackTrace
public void printStackTrace(PrintStream output)
Prints this exception's stack trace to the given print stream.- Overrides:
printStackTracein classCoreException- Parameters:
output- the print stream- Since:
- 3.0
-
printStackTrace
public void printStackTrace(PrintWriter output)
Prints this exception's stack trace to the given print writer.- Overrides:
printStackTracein classCoreException- Parameters:
output- the print writer- Since:
- 3.0
-
-