This commit is contained in:
2023-05-10 17:17:26 +08:00
parent 0af829c451
commit 076a8aed70
91 changed files with 3837 additions and 108 deletions

View File

@ -13,12 +13,12 @@
<dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<groupId>com.qiaoba</groupId>
<artifactId>qiaoba-common-base</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
</project>

View File

@ -0,0 +1,45 @@
package com.qiaoba.common.web.advice;
import com.qiaoba.common.base.exceptions.ServiceException;
import com.qiaoba.common.base.result.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 全局异常处理
*
* @author ailanyin
* @version 1.0
* @since 2021/10/15 0015 下午 16:43
*/
@ControllerAdvice
public class ExceptionAdvice {
/**
* 非自定义异常
*
* @param e Exception
* @return AjaxResult
*/
@ExceptionHandler(value = Exception.class)
@ResponseBody
public AjaxResult error(Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
}
/**
* 自定义异常, 控制台不打印
*
* @param e ServiceException
* @return AjaxResult
*/
@ExceptionHandler(ServiceException.class)
@ResponseBody
public AjaxResult handlerApiException(ServiceException e) {
return AjaxResult.error(e.getMessage());
}
}

View File

@ -0,0 +1,4 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.qiaoba.common.web.advice.ExceptionAdvice