From 4bf1bc35ae058229e588815534145094a674820c Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sat, 31 Jan 2026 00:23:20 +0100 Subject: [PATCH] Enhance supervisor office validation in falukantService: Update error handling to provide clearer messages when no supervisor position exists or when the position is vacant. This change improves user feedback during application processes by ensuring users understand the requirements for supervisor office fulfillment. --- backend/services/falukantService.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 {