|
45 | 45 | import org.springframework.http.server.ServerHttpRequest;
|
46 | 46 | import org.springframework.http.server.ServerHttpResponse;
|
47 | 47 | import org.springframework.web.bind.MethodArgumentNotValidException;
|
| 48 | +import org.springframework.web.bind.MissingServletRequestParameterException; |
48 | 49 | import org.springframework.web.bind.annotation.ExceptionHandler;
|
49 | 50 | import org.springframework.web.bind.annotation.RestController;
|
50 | 51 | import org.springframework.web.bind.annotation.RestControllerAdvice;
|
@@ -186,6 +187,24 @@ public ResponseWrapper<?> handleException(
|
186 | 187 | );
|
187 | 188 | }
|
188 | 189 |
|
| 190 | + @ExceptionHandler(MissingServletRequestParameterException.class) |
| 191 | + public ResponseWrapper<?> handleException( |
| 192 | + @NotNull MissingServletRequestParameterException missingServletRequestParameterException, |
| 193 | + @NotNull HttpServletResponse response) { |
| 194 | + response.setContentType(MediaType.APPLICATION_JSON_VALUE); |
| 195 | + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); |
| 196 | + response.setStatus(ResponseCode.REQUEST_MISSING_NECESSARY_PARAMETERS.getStatus()); |
| 197 | + logger.error(missingServletRequestParameterException.getMessage(), |
| 198 | + missingServletRequestParameterException); |
| 199 | + systemLogGrpcService.syncSubmit(SystemLogSubmitGrpcCmd.newBuilder() |
| 200 | + .setContent(missingServletRequestParameterException.getMessage()) |
| 201 | + .setCategory("missingServletRequestParameterException") |
| 202 | + .setFail(ExceptionUtils.getStackTrace(missingServletRequestParameterException)) |
| 203 | + .build()); |
| 204 | + return ResponseWrapper.failure(ResponseCode.REQUEST_MISSING_NECESSARY_PARAMETERS, |
| 205 | + missingServletRequestParameterException.getParameterName()); |
| 206 | + } |
| 207 | + |
189 | 208 | @ExceptionHandler(Exception.class)
|
190 | 209 | public ResponseWrapper<?> handleException(@NotNull Exception exception,
|
191 | 210 | @NotNull HttpServletResponse response) {
|
|
0 commit comments