WIP
authorKai Moritz <kai@juplo.de>
Sun, 13 Jun 2021 08:07:41 +0000 (10:07 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 13 Jun 2021 08:07:41 +0000 (10:07 +0200)
transfer/src/main/java/de/juplo/kafka/payment/transfer/controller/TransferController.java

index f7f9ff5..b39322a 100644 (file)
@@ -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<String, String> handleValidationExceptions(
-      MethodArgumentNotValidException ex) {
-    Map<String, String> errors = new HashMap<>();
-    ex.getBindingResult().getAllErrors().forEach((error) -> {
-      String fieldName = ((FieldError) error).getField();
-      String errorMessage = error.getDefaultMessage();
-      errors.put(fieldName, errorMessage);
-    });
-    return errors;
-  }
 }