You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
784 B
27 lines
784 B
package com.water.watersys.components; |
|
|
|
import cn.dev33.satoken.exception.NotLoginException; |
|
import cn.dev33.satoken.util.SaResult; |
|
import org.springframework.web.bind.annotation.ExceptionHandler; |
|
import org.springframework.web.bind.annotation.RestControllerAdvice; |
|
|
|
@RestControllerAdvice |
|
public class GlobalExceptionHandler { |
|
|
|
/** |
|
* 全局异常拦截,鉴权失败不会报错,会返回给前端报错原因 |
|
* @param e |
|
* @return |
|
*/ |
|
@ExceptionHandler |
|
public SaResult handlerException(Exception e) { |
|
e.printStackTrace(); |
|
return SaResult.error(e.getMessage()); |
|
} |
|
|
|
@ExceptionHandler |
|
public SaResult notLoginException(NotLoginException e){ |
|
e.printStackTrace(); |
|
return SaResult.error(e.getMessage()); |
|
} |
|
}
|
|
|