com.jupiter.tools.mvc.requester.SneakyThrow Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mvc-requester Show documentation
Show all versions of mvc-requester Show documentation
MvcRequester is a tool to make and assert REST-API communication
The newest version!
package com.jupiter.tools.mvc.requester;
import java.util.concurrent.Callable;
/**
* Created on 12.02.2019.
*
* @author Korovin Anatoliy
*/
class SneakyThrow {
private SneakyThrow() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); // $COVERAGE-IGNORE$
}
/**
* Run callable within try-catch block and wrap checked exceptions in unchecked
*
* @param callable function which may throws checked exceptions
* @param type of returned value
* @return function result
*/
static Type wrap(Callable callable) {
try {
return callable.call();
} catch (Exception e) {
throw new MvcRequestException(e);
}
}
}