fix: 修复DB层异常捕获失败

This commit is contained in:
valarchie
2023-07-18 22:21:05 +08:00
parent 4605289348
commit aa3b050b3f
3 changed files with 4 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ public class CustomExcelUtil {
writeToOutputStream(list, clazz, response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
throw new ApiException(Internal.UNKNOWN_ERROR);
throw new ApiException(e, Internal.UNKNOWN_ERROR);
}
}

View File

@@ -35,7 +35,8 @@ public class DbExceptionAspect {
try {
proceed = joinPoint.proceed();
} catch (Exception e) {
throw new ApiException(e, ErrorCode.Internal.DB_INTERNAL_ERROR, e.getCause().getMessage());
throw new ApiException(e, ErrorCode.Internal.DB_INTERNAL_ERROR,
e.getCause() != null ? e.getCause().getMessage() : ErrorCode.UNKNOWN_ERROR.message());
}
return proceed;
}

View File

@@ -89,7 +89,7 @@ logging:
springdoc:
swagger-ui:
# 开启Swagger UI界面 **安全考虑的话生产环境需要关掉**
# ***注意*** 开启Swagger UI界面 **安全考虑的话生产环境需要关掉**
# 因为knife4j的一些配置不灵活 所以重新改回springdoc+swagger的组合 真实开发的时候 使用apifox这种工具效率更高
enabled: true
url: ${agileboot.api-prefix}/v3/api-docs