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

com.github.fridujo.rabbitmq.mock.tool.Exceptions Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package com.github.fridujo.rabbitmq.mock.tool;

import java.util.function.Function;

public class Exceptions {

    public static void runAndEatExceptions(ThrowingRunnable throwingRunnable) {
        try {
            throwingRunnable.run();
        } catch (Exception unused) {
            // we are not interested in this error
        }
    }

    public static  void runAndTransformExceptions(ThrowingRunnable throwingRunnable,
                                                                       Function exceptionMapper) throws T {
        try {
            throwingRunnable.run();
        } catch (Exception original) {
            throw exceptionMapper.apply(original);
        }
    }

    public interface ThrowingRunnable {
        void run() throws Exception;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy