Commit 5433d77801e3ff17718138954716f5883946a589
1 parent
82bb0c36
fix: DataValidationException异常返回400
Showing
1 changed file
with
4 additions
and
0 deletions
... | ... | @@ -43,6 +43,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; |
43 | 43 | import org.thingsboard.server.common.data.yunteng.core.Result; |
44 | 44 | import org.thingsboard.server.common.data.yunteng.core.exception.ThingsKitException; |
45 | 45 | import org.thingsboard.server.common.msg.tools.TbRateLimitsException; |
46 | +import org.thingsboard.server.dao.exception.DataValidationException; | |
46 | 47 | import org.thingsboard.server.service.security.exception.AuthMethodNotSupportedException; |
47 | 48 | import org.thingsboard.server.service.security.exception.JwtExpiredTokenException; |
48 | 49 | import org.thingsboard.server.service.security.exception.UserPasswordExpiredException; |
... | ... | @@ -134,6 +135,9 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
134 | 135 | handleAuthenticationException((AuthenticationException) exception, response); |
135 | 136 | }else if(exception instanceof ThingsKitException){ |
136 | 137 | handleThingsKitException((ThingsKitException)exception, response); |
138 | + }else if(exception instanceof DataValidationException){ | |
139 | + response.setStatus(HttpStatus.BAD_REQUEST.value()); | |
140 | + mapper.writeValue(response.getWriter(), exception.getMessage()); | |
137 | 141 | } |
138 | 142 | else { |
139 | 143 | response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); | ... | ... |