fix(clickTtPlayerRegistrationService): improve error messaging for missing association member number
- Updated the club retrieval logic to include specific attributes, enhancing data accuracy. - Enhanced error handling to provide detailed feedback when the association member number is missing, including the club name for better context.
This commit is contained in:
@@ -47,10 +47,21 @@ class ClickTtPlayerRegistrationService {
|
||||
throw new HttpError('Mitglied nicht gefunden', 404);
|
||||
}
|
||||
|
||||
const club = await Club.findByPk(clubId);
|
||||
const associationMemberNumber = String(club?.associationMemberNumber || '').trim();
|
||||
const club = await Club.findByPk(clubId, {
|
||||
attributes: ['id', 'name', 'associationMemberNumber'],
|
||||
});
|
||||
const associationMemberNumber = String(
|
||||
club?.associationMemberNumber ??
|
||||
club?.association_member_number ??
|
||||
club?.dataValues?.associationMemberNumber ??
|
||||
club?.dataValues?.association_member_number ??
|
||||
''
|
||||
).trim();
|
||||
if (!associationMemberNumber) {
|
||||
throw new HttpError('Für den Verein ist keine Verbands-Mitgliedsnummer hinterlegt', 400);
|
||||
throw new HttpError(
|
||||
`Für den Verein "${club?.name ?? clubId}" ist keine Verbands-Mitgliedsnummer hinterlegt. Bitte in den Vereinseinstellungen unter "Verbands-Mitgliedsnummer" eintragen.`,
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
const account = await ClickTtAccount.findOne({ where: { userId } });
|
||||
|
||||
Reference in New Issue
Block a user