优化异常信息

This commit is contained in:
xxx 2023-09-04 16:41:58 +08:00
parent 4897401d32
commit 4fd23b0417
2 changed files with 9 additions and 6 deletions

View File

@ -20,11 +20,13 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import xyz.playedu.common.config.UniqueNameGeneratorConfig;
@SpringBootApplication
@EnableAsync
@EnableTransactionManagement
@ComponentScan(
basePackages = {"xyz.playedu"},
nameGenerator = UniqueNameGeneratorConfig.class)

View File

@ -37,11 +37,11 @@ import java.util.List;
@Slf4j
public class ExceptionController {
// @ExceptionHandler(Exception.class)
// public JsonResponse exceptionHandler(Exception e) {
// log.error(e.getMessage());
// return JsonResponse.error("系统错误", 500);
// }
@ExceptionHandler(Exception.class)
public JsonResponse exceptionHandler(Exception e) {
log.error(e.getMessage());
return JsonResponse.error("系统错误", 500);
}
@ExceptionHandler(ServiceException.class)
public JsonResponse serviceExceptionHandler(ServiceException e) {
@ -50,7 +50,8 @@ public class ExceptionController {
@ExceptionHandler(HttpMessageNotReadableException.class)
public JsonResponse serviceExceptionHandler(HttpMessageNotReadableException e) {
return JsonResponse.error("参数为空", 406);
log.error("error", e);
return JsonResponse.error("前端提交参数解析失败", 406);
}
@ExceptionHandler(MethodArgumentNotValidException.class)