, - . -, , . Runtime, , .
, , Runtime Exception . , :
. - , , . , , , . initCause, . :
public static <T extends Throwable> T initCause(T newException, Throwable cause) {
return (T) newException.initCause(cause);
}
.
RuntimeException Error Throwables, , , , , - :
public static void throwRuntimeExceptionFromThrowable(Throwable e) {
if (e == null) {
return;
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else if (e instanceof Error) {
throw (Error) e;
} else {
throw new RuntimeException(e.getMessage(), e);
}
}
. , ( ), , . , - :
public Object someMethod() {
try {
return getTheObject();
} catch (Exception e) {
throwRuntimeExceptionFromThrowable(e);
}
}
. .
- RuntimeException ( ) . , , .