From c779be2897f3e8b8b61c2a06fb4f1aac4f8cf44d Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 9 Feb 2026 12:03:59 +0100 Subject: [PATCH] Add error handling for nobility advancement in NobilityView: Implemented specific error messages for cooldown and unmet requirements, enhancing user feedback during advancement attempts. --- frontend/src/i18n/locales/de/falukant.json | 7 +++++- frontend/src/i18n/locales/en/falukant.json | 7 +++++- frontend/src/views/falukant/NobilityView.vue | 23 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/frontend/src/i18n/locales/de/falukant.json b/frontend/src/i18n/locales/de/falukant.json index bf8606b..5297645 100644 --- a/frontend/src/i18n/locales/de/falukant.json +++ b/frontend/src/i18n/locales/de/falukant.json @@ -738,7 +738,12 @@ "advance": { "confirm": "Aufsteigen beantragen" }, - "cooldown": "Du kannst frühestens wieder am {date} aufsteigen." + "cooldown": "Du kannst frühestens wieder am {date} aufsteigen.", + "errors": { + "tooSoon": "Aufstieg zu früh.", + "unmet": "Folgende Voraussetzungen fehlen:", + "generic": "Der Aufstieg ist fehlgeschlagen." + } }, "reputation": { "title": "Reputation", diff --git a/frontend/src/i18n/locales/en/falukant.json b/frontend/src/i18n/locales/en/falukant.json index 9a2d59f..939151f 100644 --- a/frontend/src/i18n/locales/en/falukant.json +++ b/frontend/src/i18n/locales/en/falukant.json @@ -196,7 +196,12 @@ } }, "nobility": { - "cooldown": "You can only advance again on {date}." + "cooldown": "You can only advance again on {date}.", + "errors": { + "tooSoon": "Advancement too soon.", + "unmet": "The following requirements are not met:", + "generic": "Advancement failed." + } }, "branchProduction": { "storageAvailable": "Free storage" diff --git a/frontend/src/views/falukant/NobilityView.vue b/frontend/src/views/falukant/NobilityView.vue index 79ff74f..6833485 100644 --- a/frontend/src/views/falukant/NobilityView.vue +++ b/frontend/src/views/falukant/NobilityView.vue @@ -124,6 +124,29 @@ await this.loadNobility(); } catch (err) { console.error('Error advancing nobility:', err); + const resp = err?.response; + if (resp?.status === 412) { + if (resp.data?.message === 'nobilityTooSoon') { + const retryAtIso = resp.data?.retryAt; + const retryStr = retryAtIso ? this.formatDate(retryAtIso) : ''; + const msg = this.$t('falukant.nobility.errors.tooSoon'); + this.$root.$refs.errorDialog?.open(retryStr ? `${msg} — ${this.$t('falukant.nobility.cooldown', { date: retryStr })}` : msg); + } else if (resp.data?.message === 'nobilityRequirements') { + const unmet = resp.data?.unmet || []; + const items = unmet.map(u => { + if (u.type === 'money') return this.$t('falukant.nobility.requirement.money', { amount: this.formatCost(u.required) }); + if (u.type === 'cost') return this.$t('falukant.nobility.requirement.cost', { amount: this.formatCost(u.required) }); + if (u.type === 'branches') return this.$t('falukant.nobility.requirement.branches', { amount: u.required }); + return `${u.type}: ${u.required}`; + }).join('\n'); + const base = this.$t('falukant.nobility.errors.unmet'); + this.$root.$refs.errorDialog?.open(`${base}\n${items}`); + } else { + this.$root.$refs.errorDialog?.open('tr:falukant.nobility.errors.generic'); + } + } else { + this.$root.$refs.errorDialog?.open('tr:falukant.nobility.errors.generic'); + } } finally { this.isAdvancing = false; }