This commit is contained in:
2025-12-16 21:44:20 +01:00
parent 7532c7ed6d
commit 8c67081953
38 changed files with 818 additions and 1321 deletions

View File

@@ -8,18 +8,18 @@ import type {
AllRacesFilterOptionsViewModel,
} from '../presenters/IAllRacesPagePresenter';
import type { AsyncUseCase } from '@core/shared/application';
import { Result } from '@/shared/application/Result';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
export class GetAllRacesPageDataUseCase
implements AsyncUseCase<void, AllRacesPageResultDTO, string> {
implements AsyncUseCase<void, AllRacesPageResultDTO, 'REPOSITORY_ERROR'> {
constructor(
private readonly raceRepository: IRaceRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly logger: Logger,
) {}
async execute(): Promise<Result<AllRacesPageResultDTO, ApplicationErrorCode<string>>> {
async execute(): Promise<Result<AllRacesPageResultDTO, ApplicationErrorCode<'REPOSITORY_ERROR', { message: string }>>> {
this.logger.debug('Executing GetAllRacesPageDataUseCase');
try {
const [allRaces, allLeagues] = await Promise.all([
@@ -69,7 +69,10 @@ export class GetAllRacesPageDataUseCase
return Result.ok(viewModel);
} catch (error) {
this.logger.error('Error executing GetAllRacesPageDataUseCase', error instanceof Error ? error : new Error(String(error)));
return Result.err(new RacingDomainValidationError(error instanceof Error ? error.message : 'Unknown error occurred'));
return Result.err({
code: 'REPOSITORY_ERROR',
details: { message: error instanceof Error ? error.message : 'Unknown error occurred' },
});
}
}
}