| | |
| | | // |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import com.vci.ubcs.starter.web.util.MessageUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.text.MessageFormat; |
| | | |
| | | public class VciBaseException extends RuntimeException { |
| | | public class VciBaseException extends ServiceException { |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | public static final String paramNull = "com.vci.base.paramNull"; |
| | | public static final String fieldValueRepeat = "com.vci.base.fieldValueRepeat"; |
| | |
| | | private Object[] objs = new Object[0]; |
| | | |
| | | public VciBaseException(String code) { |
| | | super(code); |
| | | this.code = code; |
| | | } |
| | | |
| | | public VciBaseException(String code, Object[] objs) { |
| | | super(code); |
| | | this.code = code; |
| | | this.objs = objs; |
| | | } |
| | | |
| | | public VciBaseException(String code, Object[] objs, Throwable e) { |
| | | super(e); |
| | | super(code); |
| | | this.code = code; |
| | | this.objs = objs; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取异常信息 |
| | | * @param e 异常对象 |
| | | * @return 异常对象上的所有内容 |
| | | */ |
| | | public static String getErrorMsgByE(Throwable e){ |
| | | if(e == null){ |
| | | return "未知错误"; |
| | | } |
| | | if( e.getClass()!= null && e.getClass().getSuperclass()!= null && |
| | | (e.getClass().getSuperclass().equals(RuntimeException.class) |
| | | || e.getClass().getSuperclass().getName().endsWith(".VciBaseException") |
| | | || e.getClass().getName().endsWith(".VciBaseException"))){ |
| | | //说明是我们自定义的异常类 |
| | | try { |
| | | Method errorMethod = e.getClass().getMethod("getErrorMsg"); |
| | | if(errorMethod != null ){ |
| | | return (String)errorMethod.invoke(e); |
| | | } |
| | | } catch (NoSuchMethodException e1) { |
| | | return e.getMessage(); |
| | | } catch (IllegalAccessException e1) { |
| | | return e.getMessage(); |
| | | } catch (InvocationTargetException e1) { |
| | | return e.getMessage(); |
| | | } |
| | | } |
| | | return e.getMessage(); |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return this.getCode() + "," + this.getErrorMsg(); |