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

top.remliyx.dbeasy.utils.exception.base.BizException Maven / Gradle / Ivy

There is a newer version: 2.0.0-RELEASE
Show newest version
package top.remliyx.dbeasy.utils.exception.base;

import java.util.Properties;

/**
 * 文件说明:
 * 创建作者: 李宜栩
 * 创建日期: 2023-6-29
 * 版权所有:lyx
 * 版本:    Version 1.0
 */
public class BizException extends Exception{
    private static final long serialVersionUID = -6417613796687468770L;
    private static Properties PROPERTIES;

    public static void initProperties(Properties properties) {
        PROPERTIES = properties;
    }

    public BizException(String code, Object... args) {
        super(getProperty(code, args));
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
    }

    public BizException(String code, Throwable e, Object... args) {
        super(getProperty(code, args), e);
    }

    public static String getProperty(String code, Object... args) {
        String value = PROPERTIES.getProperty(code);
        if (value == null) {
            value = code;
        }

        if (args != null) {
            value = String.format(value, args);
        }

        return value;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy