Send 400 instead of 500 when tournament failes to save

This commit is contained in:
2025-08-15 09:30:25 +02:00
parent 3365c19f78
commit e154c7e4d7

View File

@@ -13,6 +13,7 @@ import nl.connectedit.swiss.service.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.time.format.DateTimeParseException;
import java.util.List;
import java.util.Objects;
@@ -68,7 +69,7 @@ public class TournamentController {
Tournament tournament;
try {
tournament = tournamentMapper.toEntity(tournamentDto);
} catch (NullPointerException e) {
} catch (NullPointerException | DateTimeParseException e) {
return ResponseEntity.badRequest().build();
}
return ResponseEntity.ok(tournamentMapper.toDto(tournamentService.saveTournament(tournament)));