8 changed files with 68 additions and 92 deletions
			
			
		- 
					33common/src/main/java/com/canvas/web/exception/CustomException.java
- 
					20common/src/main/java/com/canvas/web/exception/GlobalExceptionHandler.java
- 
					14common/src/main/java/com/canvas/web/exception/user/CaptchaException.java
- 
					14common/src/main/java/com/canvas/web/exception/user/UserException.java
- 
					12common/src/main/java/com/canvas/web/exception/user/UserNotExistsException.java
- 
					60common/src/main/java/com/canvas/web/utils/Response.java
- 
					3system/src/main/java/com/canvas/web/modules/system/controller/UserController.java
| @ -1,33 +0,0 @@ | |||||
| package com.canvas.web.exception; |  | ||||
| 
 |  | ||||
| 
 |  | ||||
| //自定义异常类 |  | ||||
| public class CustomException extends RuntimeException { |  | ||||
| 
 |  | ||||
|     private static final long serialVersionUID = 1L; |  | ||||
| 
 |  | ||||
|     private Integer code; |  | ||||
| 
 |  | ||||
|     private String message; |  | ||||
| 
 |  | ||||
|     public CustomException(String message) { this.message=message;} |  | ||||
| 
 |  | ||||
|     public CustomException(String message ,Integer code){ |  | ||||
|         this.message=message; |  | ||||
|         this.code=code; |  | ||||
|     } |  | ||||
| 
 |  | ||||
|     public CustomException(String message,Throwable e){ |  | ||||
|         super(message,e); |  | ||||
|         this.message=message; |  | ||||
|     } |  | ||||
| 
 |  | ||||
|     @Override |  | ||||
|     public String getMessage() { |  | ||||
|         return message; |  | ||||
|     } |  | ||||
| 
 |  | ||||
|     public Integer getCode() { |  | ||||
|         return code; |  | ||||
|     } |  | ||||
| } |  | ||||
| @ -0,0 +1,20 @@ | |||||
|  | package com.canvas.web.exception; | ||||
|  | 
 | ||||
|  | import com.canvas.web.utils.Response; | ||||
|  | import org.slf4j.Logger; | ||||
|  | import org.slf4j.LoggerFactory; | ||||
|  | import org.springframework.web.bind.annotation.ControllerAdvice; | ||||
|  | 
 | ||||
|  | import javax.servlet.http.HttpServletRequest; | ||||
|  | 
 | ||||
|  | @ControllerAdvice | ||||
|  | public class GlobalExceptionHandler { | ||||
|  |     private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | //    public Response baseExceptionHandler(HttpServletRequest req,BaseException e){ | ||||
|  | //        logger.error("发生业务异常!原因是:{}",e.getDefaultMessage()); | ||||
|  | //        return Response.error(e.getCode(),e.getDefaultMessage()); | ||||
|  | //    } | ||||
|  | } | ||||
| @ -1,14 +0,0 @@ | |||||
| package com.canvas.web.exception.user; |  | ||||
| 
 |  | ||||
| 
 |  | ||||
| import com.canvas.web.exception.BaseException; |  | ||||
| 
 |  | ||||
| //验证码处理异常 |  | ||||
| public class CaptchaException extends UserException { |  | ||||
| 
 |  | ||||
|     private static final long seriaVersionUID = 1L; |  | ||||
| 
 |  | ||||
|     public CaptchaException() { |  | ||||
|         super("user.jcaptcha.error", null); |  | ||||
|     } |  | ||||
| } |  | ||||
| @ -1,14 +0,0 @@ | |||||
| package com.canvas.web.exception.user; |  | ||||
| 
 |  | ||||
| 
 |  | ||||
| import com.canvas.web.exception.BaseException; |  | ||||
| 
 |  | ||||
| //用户处理异常 |  | ||||
| public class UserException extends BaseException { |  | ||||
| 
 |  | ||||
|     private static final long serialVersionUID = 1L; |  | ||||
| 
 |  | ||||
|     public UserException(String code, Object[] args) { |  | ||||
|         super("user", code, args, null); |  | ||||
|     } |  | ||||
| } |  | ||||
| @ -1,12 +0,0 @@ | |||||
| package com.canvas.web.exception.user; |  | ||||
| 
 |  | ||||
| 
 |  | ||||
| //用户不存在异常 |  | ||||
| public class UserNotExistsException extends UserException { |  | ||||
| 
 |  | ||||
|     private static final long seriaVersionUID = 1L; |  | ||||
| 
 |  | ||||
|     public UserNotExistsException() { |  | ||||
|         super("user.not.exits",null); |  | ||||
|     } |  | ||||
| } |  | ||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue