This commit is contained in:
2025-12-11 11:25:22 +01:00
parent 6a427eab57
commit e4c1be628d
86 changed files with 1222 additions and 736 deletions

View File

@@ -3,6 +3,10 @@ import type { ILeagueRepository } from '../../domain/repositories/ILeagueReposit
import type { IResultRepository } from '../../domain/repositories/IResultRepository';
import type { IStandingRepository } from '../../domain/repositories/IStandingRepository';
import { Result } from '../../domain/entities/Result';
import {
BusinessRuleViolationError,
EntityNotFoundError,
} from '../errors/RacingApplicationError';
import type {
IImportRaceResultsPresenter,
ImportRaceResultsSummaryViewModel,
@@ -37,17 +41,17 @@ export class ImportRaceResultsUseCase {
const race = await this.raceRepository.findById(raceId);
if (!race) {
throw new Error('Race not found');
throw new EntityNotFoundError({ entity: 'race', id: raceId });
}
const league = await this.leagueRepository.findById(race.leagueId);
if (!league) {
throw new Error('League not found');
throw new EntityNotFoundError({ entity: 'league', id: race.leagueId });
}
const existing = await this.resultRepository.existsByRaceId(raceId);
if (existing) {
throw new Error('Results already exist for this race');
throw new BusinessRuleViolationError('Results already exist for this race');
}
const entities = results.map((dto) =>