Commit 0e07966d583ef34d425f663f23b33fd8ddb28433

Authored by 云中非
1 parent 84c1d09d

fix: EntityCreationException异常返回500的问题

... ... @@ -5,10 +5,7 @@ import org.springframework.security.access.AccessDeniedException;
5 5 import org.springframework.web.bind.MethodArgumentNotValidException;
6 6 import org.springframework.web.bind.annotation.ControllerAdvice;
7 7 import org.springframework.web.bind.annotation.ExceptionHandler;
8   -import org.thingsboard.server.common.data.yunteng.core.exception.NoneTenantAssetException;
9   -import org.thingsboard.server.common.data.yunteng.core.exception.TooManyRequestException;
10   -import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
11   -import org.thingsboard.server.common.data.yunteng.core.exception.YunTengException;
  8 +import org.thingsboard.server.common.data.yunteng.core.exception.*;
12 9 import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
13 10 import org.thingsboard.server.exception.yunteng.YunTengErrorResponseHandler;
14 11
... ... @@ -75,4 +72,13 @@ public class ControllerExceptionHandler {
75 72 ErrorMessage.NONE_TENANT_ASSET.setMessage(ex.getMessage()), HttpStatus.NOT_FOUND),
76 73 response);
77 74 }
  75 +
  76 + @ExceptionHandler(EntityCreationException.class)
  77 + public void handleEntityCreationException(
  78 + EntityCreationException ex, HttpServletResponse response) {
  79 + response.setCharacterEncoding("utf-8");
  80 + errorResponseHandler.handle(
  81 + new YunTengException(ErrorMessage.SEND_DESTINATION_NOT_FOUND, HttpStatus.PRECONDITION_FAILED),
  82 + response);
  83 + }
78 84 }
... ...