From 3c463114918a08d2e727e7e3a656363afb4a5452 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 13 Jun 2021 10:07:41 +0200 Subject: [PATCH] WIP --- .../controller/TransferController.java | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/transfer/src/main/java/de/juplo/kafka/payment/transfer/controller/TransferController.java b/transfer/src/main/java/de/juplo/kafka/payment/transfer/controller/TransferController.java index f7f9ff5..b39322a 100644 --- a/transfer/src/main/java/de/juplo/kafka/payment/transfer/controller/TransferController.java +++ b/transfer/src/main/java/de/juplo/kafka/payment/transfer/controller/TransferController.java @@ -5,18 +5,12 @@ import de.juplo.kafka.payment.transfer.domain.Transfer; import de.juplo.kafka.payment.transfer.domain.TransferService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.validation.FieldError; -import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.net.URI; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; @RestController @@ -60,17 +54,4 @@ import java.util.Optional; .map(transfer -> ResponseEntity.ok(TransferDTO.of(transfer))) .orElse(ResponseEntity.notFound().build()); } - - @ResponseStatus(HttpStatus.BAD_REQUEST) - @ExceptionHandler(MethodArgumentNotValidException.class) - public Map handleValidationExceptions( - MethodArgumentNotValidException ex) { - Map errors = new HashMap<>(); - ex.getBindingResult().getAllErrors().forEach((error) -> { - String fieldName = ((FieldError) error).getField(); - String errorMessage = error.getDefaultMessage(); - errors.put(fieldName, errorMessage); - }); - return errors; - } } -- 2.20.1