All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jupiter.tools.mvc.requester.SneakyThrow Maven / Gradle / Ivy

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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy