package com.lanyuanxiaoyao.service.common.exception;

import java.util.function.Supplier;

/**
 * 配置异常
 *
 * @author ZhangJiacheng
 * @date 2022-05-16
 */
public class ConfigException extends Exception {
    public ConfigException(String message) {
        super(message);
    }

    public static void check(String message, Supplier<Boolean> checkFunction) throws ConfigException {
        if (checkFunction.get()) {
            throw new ConfigException(message);
        }
    }

    public static void checkQuiet(String message, Supplier<Boolean> checkFunction) {
        try {
            check(message, checkFunction);
        } catch (ConfigException e) {
            throw new RuntimeException(e);
        }
    }
}
