Top Description Fields Constructors Methods
org.springframework.core

public abstract Class NestedRuntimeException

extends RuntimeException
Class Inheritance
Known Direct Subclasses
org.springframework.core.annotation.AnnotationConfigurationException, org.springframework.core.codec.CodecException, org.springframework.core.convert.ConversionException, org.springframework.core.serializer.support.SerializationFailedException
Imports
org.springframework.lang.Nullable

Handy class for wrapping runtime Exceptions with a root cause. This class is abstract to force the programmer to extend the class.

The similarity between this class and the NestedCheckedException class is unavoidable, as Java forces these two classes to have different superclasses (ah, the inflexibility of concrete inheritance!).

Authors
Rod Johnson, Juergen Hoeller
See Also
getMessage, NestedCheckedException

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Use serialVersionUID from Spring 1.2 for interoperability.

Constructor Summary

AccessConstructor and Description
public
NestedRuntimeException(String
the detail message
msg
)

Construct a NestedRuntimeException with the specified detail message.

public
NestedRuntimeException(String
the detail message
msg
,
Throwable
the nested exception
cause
)

Construct a NestedRuntimeException with the specified detail message and nested exception.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether there is a nested exception of the specified type
contains
(Class<?>
the exception type to look for
exType
)

Check whether this exception contains an exception of the given type: either it is of the given class itself or it contains a nested cause of the given type.

public Throwable

Returns:

the most specific cause (never null)
getMostSpecificCause
()

Retrieve the most specific cause of this exception, that is, either the innermost cause (root cause) or this exception itself.

public Throwable

Returns:

the innermost exception, or null if none
getRootCause
()

Retrieve the innermost cause of this exception, if any.

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Use serialVersionUID from Spring 1.2 for interoperability.

Constructor Detail

NestedRuntimeExceptionback to summary
public NestedRuntimeException(String msg)

Construct a NestedRuntimeException with the specified detail message.

Parameters
msg:String

the detail message

NestedRuntimeExceptionback to summary
public NestedRuntimeException(String msg, Throwable cause)

Construct a NestedRuntimeException with the specified detail message and nested exception.

Parameters
msg:String

the detail message

cause:Throwable

the nested exception

Method Detail

containsback to summary
public boolean contains(Class<?> exType)

Check whether this exception contains an exception of the given type: either it is of the given class itself or it contains a nested cause of the given type.

Parameters
exType:Class<?>

the exception type to look for

Returns:boolean

whether there is a nested exception of the specified type

getMostSpecificCauseback to summary
public Throwable getMostSpecificCause()

Retrieve the most specific cause of this exception, that is, either the innermost cause (root cause) or this exception itself.

Differs from getRootCause() in that it falls back to the present exception if there is no root cause.

Returns:Throwable

the most specific cause (never null)

Since
2.0.3
getRootCauseback to summary
public Throwable getRootCause()

Retrieve the innermost cause of this exception, if any.

Returns:Throwable

the innermost exception, or null if none

Annotations
@Nullable
Since
2.0