Skip to content

Commit

Permalink
throw error when round does not started
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Oct 2, 2024
1 parent 5a1f9fa commit bbb549f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/repositories/projectRoundRecordRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EarlyAccessRound } from '../entities/earlyAccessRound';
import { ProjectRoundRecord } from '../entities/projectRoundRecord';
import { QfRound } from '../entities/qfRound';
import { logger } from '../utils/logger';
import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages';

/**
* Create or update the donation summary for the specified project, QfRound, and EarlyAccessRound.
Expand Down Expand Up @@ -74,7 +75,9 @@ export async function updateOrCreateProjectRoundRecord(
return prr;
} catch (error) {
logger.error('Error updating or creating ProjectRoundRecord:', error);
throw new Error('Failed to update or create ProjectRoundRecord');
throw new Error(
`Failed to update or create ProjectRoundRecord, ${error.message}`,
);
}
}

Expand Down Expand Up @@ -109,16 +112,20 @@ export async function getCumulativePastRoundsDonationAmounts({
if (earlyAccessRoundId) {
round = await EarlyAccessRound.findOneBy({ id: earlyAccessRoundId });
if (!round?.startDate || round.startDate > new Date()) {
return null;
throw new Error(
i18n.__(translationErrorMessagesKeys.ROUND_DOES_NOT_STARTED),
);
}
} else if (qfRoundId) {
round = await QfRound.findOneBy({ id: qfRoundId });
if (!round?.beginDate || round.beginDate > new Date()) {
return null;
throw new Error(
i18n.__(translationErrorMessagesKeys.ROUND_DOES_NOT_STARTED),
);
}
} else {
// No round specified
return null;
throw new Error(i18n.__(translationErrorMessagesKeys.NO_ROUND_SPECIFIED));
}

try {
Expand Down

0 comments on commit bbb549f

Please sign in to comment.