diff --git a/src/main/java/com/rymcu/forest/config/BaseExceptionHandler.java b/src/main/java/com/rymcu/forest/config/BaseExceptionHandler.java index 632a1ad..ee053fd 100644 --- a/src/main/java/com/rymcu/forest/config/BaseExceptionHandler.java +++ b/src/main/java/com/rymcu/forest/config/BaseExceptionHandler.java @@ -1,6 +1,7 @@ package com.rymcu.forest.config; import com.alibaba.fastjson.support.spring.FastJsonJsonView; +import com.rymcu.forest.core.exception.DataDuplicationException; import com.rymcu.forest.core.exception.ServiceException; import com.rymcu.forest.core.exception.TransactionException; import com.rymcu.forest.core.result.GlobalResult; @@ -62,6 +63,9 @@ public class BaseExceptionHandler { } else if (ex instanceof ServletException) { result.setCode(ResultCode.FAIL.getCode()); result.setMessage(ex.getMessage()); + } else if (ex instanceof DataDuplicationException) { + result.setCode(ResultCode.FAIL.getCode()); + result.setMessage(ex.getMessage()); } else if (ex instanceof TransactionException) { result.setCode(TransactionCode.InsufficientBalance.getCode()); result.setMessage(ex.getMessage()); @@ -108,6 +112,9 @@ public class BaseExceptionHandler { } else if (ex instanceof ServletException) { attributes.put("code", ResultCode.FAIL.getCode()); attributes.put("message", ex.getMessage()); + } else if (ex instanceof DataDuplicationException) { + attributes.put("code", ResultCode.FAIL.getCode()); + attributes.put("message", ex.getMessage()); } else if (ex instanceof TransactionException) { attributes.put("code", TransactionCode.InsufficientBalance.getCode()); attributes.put("message", ex.getMessage()); diff --git a/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java b/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java index 6d50510..0e5faa2 100644 --- a/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java +++ b/src/main/java/com/rymcu/forest/core/exception/DataDuplicationException.java @@ -1,5 +1,8 @@ package com.rymcu.forest.core.exception; +/** + * @author KKould + */ public class DataDuplicationException extends RuntimeException { private static final long serialVersionUID = 3206744387536223284L;