Browse Source

回调出错,打印日志

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
aa71b9088f
2 changed files with 7 additions and 0 deletions
  1. +4
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/advice/CustomExceptionHandler.java
  2. +3
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java

+ 4
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/advice/CustomExceptionHandler.java View File

@@ -34,6 +34,7 @@ public class CustomExceptionHandler {
@ExceptionHandler(BindException.class)
@ResponseBody
public JsonResult<Object> handleAuthenticationException(BindException e) {
e.printStackTrace();
BindingResult bindingResult = e.getBindingResult();
String errorMessage = "";
for (FieldError fieldError : bindingResult.getFieldErrors()) {
@@ -48,6 +49,7 @@ public class CustomExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseBody
public JsonResult<Object> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
e.printStackTrace();
log.warn("系统参数校验异常,异常信息:{}", e.getMessage());

JsonResult<Object> error = JsonResult.error(SysExceptionEnum.PARAMETER_EMPTY_EXCEPTION.getCode(),
@@ -73,6 +75,7 @@ public class CustomExceptionHandler {
@ExceptionHandler(ServiceException.class)
@ResponseBody
public JsonResult<Object> handleServiceException(ServiceException e) {
e.printStackTrace();
// 打印业务异常日志
log.warn("系统业务逻辑异常,异常状态码 {},异常信息:{}", e.code, e.getMessage());
return JsonResult.error(e.code, e.getMessage());
@@ -98,6 +101,7 @@ public class CustomExceptionHandler {
@ExceptionHandler(DataAccessException.class)
@ResponseBody
public JsonResult<Object> handleDataAccessException(DataAccessException e) {
e.printStackTrace();
log.error("系统数据访问异常,异常信息:{}", e.getMessage());
return JsonResult.error(SysExceptionEnum.DATAACCESS_EXCEPTION.getCode(), SysExceptionEnum.DATAACCESS_EXCEPTION.getMessage());
}

+ 3
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/QuestionController.java View File

@@ -6,6 +6,7 @@ import com.tuoheng.admin.entity.request.*;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVO;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.common.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -23,6 +24,7 @@ import java.util.Map;
*/
@RestController
@RequestMapping("/question")
@Slf4j
public class QuestionController {

@Autowired
@@ -50,6 +52,7 @@ public class QuestionController {
public JsonResult callback(@Valid @Pattern(regexp = "^[a-zA-Z0-9]{0,36}$")
@NotBlank @PathVariable("requestId") String requestId,
@Valid @RequestBody CallbackRequest callbackRequest) {
log.info("进入回调地址,回调参数callbackRequest为:{},requestId为:{}",callbackRequest,requestId);
return questionService.process(requestId, callbackRequest);
}


Loading…
Cancel
Save