Send 400 instead of 500 when tournament failes to save
This commit is contained in:
@@ -13,6 +13,7 @@ import nl.connectedit.swiss.service.*;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class TournamentController {
|
|||||||
Tournament tournament;
|
Tournament tournament;
|
||||||
try {
|
try {
|
||||||
tournament = tournamentMapper.toEntity(tournamentDto);
|
tournament = tournamentMapper.toEntity(tournamentDto);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException | DateTimeParseException e) {
|
||||||
return ResponseEntity.badRequest().build();
|
return ResponseEntity.badRequest().build();
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(tournamentMapper.toDto(tournamentService.saveTournament(tournament)));
|
return ResponseEntity.ok(tournamentMapper.toDto(tournamentService.saveTournament(tournament)));
|
||||||
|
|||||||
Reference in New Issue
Block a user