Skip to content

Commit 745b463

Browse files
committed
feat: add exception handling for MethodArgumentNotValidException and update UtmModuleConfigValidator logic
1 parent f98cb0b commit 745b463

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

backend/src/main/java/com/park/utmstack/advice/GlobalExceptionHandler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.http.HttpStatus;
1111
import org.springframework.http.ResponseEntity;
1212
import org.springframework.security.authentication.BadCredentialsException;
13+
import org.springframework.web.bind.MethodArgumentNotValidException;
1314
import org.springframework.web.bind.annotation.ExceptionHandler;
1415
import org.springframework.web.bind.annotation.RestControllerAdvice;
1516

@@ -60,6 +61,11 @@ public ResponseEntity<?> handleConflict(Exception e, HttpServletRequest request)
6061
return ResponseUtil.buildErrorResponse(HttpStatus.CONFLICT, e.getMessage());
6162
}
6263

64+
@ExceptionHandler(MethodArgumentNotValidException.class)
65+
public ResponseEntity<?> handleMethodArgumentNotValid(MethodArgumentNotValidException e, HttpServletRequest request) {
66+
return ResponseUtil.buildBadRequestResponse(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
67+
}
68+
6369
@ExceptionHandler(Exception.class)
6470
public ResponseEntity<?> handleGenericException(Exception e, HttpServletRequest request) {
6571
return ResponseUtil.buildInternalServerErrorResponse(e.getMessage());

backend/src/main/java/com/park/utmstack/domain/application_modules/validators/UtmModuleConfigValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public boolean validate(UtmModule module, List<UtmModuleGroupConfiguration> keys
3434

3535
return new UtmModuleGroupConfDTO(
3636
source.getConfKey(),
37-
decryptIfNeeded(source.getConfDataType(), source.getConfValue())
37+
override != null ? source.getConfValue() : decryptIfNeeded(source.getConfDataType(), source.getConfValue())
3838
);
3939
})
4040
.toList();

0 commit comments

Comments
 (0)