Commit d3584230fb0cfb7ee63134ff77ff6f263c834a56
1 parent
815ffbca
fix(DEFECT-1523): 非业务异常日志问题修复
非业务相关的运行时异常,记录到异常日志
Showing
1 changed file
with
13 additions
and
9 deletions
... | ... | @@ -36,18 +36,22 @@ public class ThingsKitExceptionHandler { |
36 | 36 | private final AuditLogService auditLogService; |
37 | 37 | private final ThingsboardErrorResponseHandler errorResponseHandler; |
38 | 38 | |
39 | - @ExceptionHandler(MethodArgumentNotValidException.class) | |
39 | + @ExceptionHandler(RuntimeException.class) | |
40 | 40 | public void handleMethodArgumentNotValidException( |
41 | - MethodArgumentNotValidException ex, | |
41 | + RuntimeException ex, | |
42 | 42 | HttpServletRequest request, |
43 | 43 | HttpServletResponse response) { |
44 | - produceLog(request, ex); | |
45 | - errorResponseHandler.handle( | |
46 | - new ThingsKitException( | |
47 | - ErrorMessage.INVALID_PARAMETER.setMessage( | |
48 | - Objects.requireNonNull(ex.getBindingResult().getFieldError()).getDefaultMessage()), | |
49 | - HttpStatus.BAD_REQUEST), | |
50 | - response); | |
44 | + if(ex instanceof ThingsKitException){ | |
45 | + errorResponseHandler.handle( | |
46 | + new ThingsKitException( | |
47 | + ErrorMessage.INVALID_PARAMETER.setMessage( | |
48 | + ex.getMessage()), | |
49 | + HttpStatus.BAD_REQUEST), | |
50 | + response); | |
51 | + }else{ | |
52 | + produceLog(request, ex); | |
53 | + errorResponseHandler.handle(ex,response); | |
54 | + } | |
51 | 55 | } |
52 | 56 | |
53 | 57 | protected SecurityUser getCurrentUser() throws ThingsboardException { | ... | ... |