
de.larssh.utils.test.SneakyException Maven / Gradle / Ivy
// Generated by delombok at Thu Aug 29 22:55:59 CEST 2019
package de.larssh.utils.test;
import de.larssh.utils.annotations.PackagePrivate;
/**
* SneakyException allow rethrowing any kind of {@link Exception}, hiding them
* from compiler checks.
*
*
* The calling method should either:
*
* - have a {@code throws} statement for the hidden exceptions
*
- handle hidden exceptions using {@code catch}
*
- or at least document the hidden exceptions in JavaDoc using
* {@code @throws}.
*
*
*
* This class has been copied from "utils" module and must not be used
* publicly!
*/
@PackagePrivate
final class SneakyException extends RuntimeException {
private static final long serialVersionUID = 1;
/**
* Rethrows {@code throwable}, hiding it from compiler checks.
*
*
* The calling method should either:
*
* - have a {@code throws} statement for the hidden exceptions
*
- handle hidden exceptions using {@code catch}
*
- or at least document the hidden exceptions in JavaDoc using
* {@code @throws}.
*
*
* @param throwable throwable to be hidden
*/
@PackagePrivate
SneakyException(final Throwable throwable) {
super(throwable);
rethrow(throwable);
}
/**
* Rethrows {@code throwable}, hiding it from compiler checks.
*
*
* This is not part of the constructor to hide the public API from generic type
* {@code T}.
*
* @param generic throwable
* @param throwable throwable to be hidden
* @throws T hidden throwable
*/
@SuppressWarnings("unchecked")
private void rethrow(final Throwable throwable) throws T {
throw (T) throwable;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy