package cn.autoform.fw.exception; import cn.autoform.util.tool.ObjectUtil; import com.iemsoft.framework.cloud.core.tools.MsgTool; import org.apache.commons.lang3.StringUtils; /** * 运行时异常类 * @author WangYX * */ public class IEMRuntimeException extends RuntimeException { /** * */ private static final long serialVersionUID = 1L; private String code; private String[] args; private IEMRuntimeException childIEMExc; public IEMRuntimeException(String code, String... args) { super(); this.code = code; this.args = args; } public IEMRuntimeException setchildIEMExc(IEMRuntimeException childIEMExc) { this.childIEMExc = childIEMExc; return this; } public IEMRuntimeException setchildIEMExc(String code, String... args) { this.childIEMExc = new IEMRuntimeException(code, args); return this; } public String getCode() { return code; } @Override public String getMessage() { String childMsg = childIEMExc == null ? "" : childIEMExc.getMessage(); String msg = MsgTool.get(code, args); if(StringUtils.isNotBlank(childMsg)){ return String.format("%s[%s]", ObjectUtil.empty(msg) ? code : msg, childMsg); }else{ return ObjectUtil.empty(msg) ? code : msg; } } }