diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index a0a88f3..6ff6623 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -5583,7 +5583,7 @@ ORDER BY r.id`, { model: ChurchOfficeType, as: 'type', - attributes: ['hierarchyLevel'] + attributes: ['id', 'name', 'hierarchyLevel'] }, { model: FalukantCharacter, @@ -5597,8 +5597,12 @@ ORDER BY r.id`, limit: 1 }); - if (!supervisorOffice || !supervisorOffice.holder) { - throw new Error('No supervisor found for this position'); + if (!supervisorOffice) { + throw new Error('No supervisor position exists in this region. Higher church offices must be filled before you can apply.'); + } + if (!supervisorOffice.holder) { + const officeName = supervisorOffice.type?.name || 'higher'; + throw new Error(`The ${officeName} position in this region is vacant. It must be filled before you can apply.`); } supervisorId = supervisorOffice.holder.id; } else {