Enhance health activity error handling: Implement detailed error responses in FalukantController for 'tooClose' scenarios, including retry timing. Update localization files for improved user feedback on health measures and errors. Refactor error handling in HealthView to display appropriate messages based on error responses.
This commit is contained in:
@@ -895,7 +895,12 @@
|
||||
"drunkOfLife": "Trunk des Lebens",
|
||||
"barber": "Barbier"
|
||||
},
|
||||
"choose": "Bitte auswählen"
|
||||
"choose": "Bitte auswählen",
|
||||
"errors": {
|
||||
"tooClose": "Du kannst nicht so oft Maßnahmen durchführen.",
|
||||
"generic": "Ein Fehler ist aufgetreten."
|
||||
},
|
||||
"nextMeasureAt": "Nächste Maßnahme ab"
|
||||
},
|
||||
"politics": {
|
||||
"title": "Politik",
|
||||
|
||||
@@ -197,7 +197,32 @@
|
||||
},
|
||||
"nobility": {
|
||||
"cooldown": "You can only advance again on {date}."
|
||||
},
|
||||
},
|
||||
"healthview": {
|
||||
"title": "Health",
|
||||
"age": "Age",
|
||||
"status": "Health Status",
|
||||
"measuresTaken": "Measures Taken",
|
||||
"measure": "Measure",
|
||||
"date": "Date",
|
||||
"cost": "Cost",
|
||||
"success": "Success",
|
||||
"selectMeasure": "Select Measure",
|
||||
"perform": "Perform",
|
||||
"measures": {
|
||||
"pill": "Pill",
|
||||
"doctor": "Doctor Visit",
|
||||
"witch": "Witch",
|
||||
"drunkOfLife": "Elixir of Life",
|
||||
"barber": "Barber"
|
||||
},
|
||||
"choose": "Please select",
|
||||
"errors": {
|
||||
"tooClose": "You cannot perform measures so often.",
|
||||
"generic": "An error occurred."
|
||||
},
|
||||
"nextMeasureAt": "Next measure from"
|
||||
},
|
||||
"branchProduction": {
|
||||
"storageAvailable": "Free storage"
|
||||
},
|
||||
|
||||
@@ -142,9 +142,23 @@ export default {
|
||||
this.selectedTr = '';
|
||||
} catch (err) {
|
||||
console.error('Error performing measure', err);
|
||||
const title = this.$t('falukant.healthview.title');
|
||||
const remoteMsg = err?.response?.data?.error || err?.message || String(err);
|
||||
this.$root.$refs.messageDialog?.open(remoteMsg, title);
|
||||
if (err?.response?.status === 412) {
|
||||
const retryAtIso = err.response?.data?.retryAt;
|
||||
const code = err.response?.data?.error || err.response?.data?.message;
|
||||
if (retryAtIso) {
|
||||
const retryStr = new Date(retryAtIso).toLocaleString(navigator.language, {
|
||||
year: 'numeric', month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
});
|
||||
const baseMsg = this.$t(`falukant.healthview.errors.${code}`);
|
||||
this.$root.$refs.errorDialog?.open(`${baseMsg} — ${this.$t('falukant.healthview.nextMeasureAt')}: ${retryStr}`);
|
||||
} else {
|
||||
this.$root.$refs.errorDialog?.open(this.$t(`falukant.healthview.errors.${code}`));
|
||||
}
|
||||
} else {
|
||||
const code = err?.response?.data?.error || err?.message || 'generic';
|
||||
this.$root.$refs.errorDialog?.open(this.$t(`falukant.healthview.errors.${code}`) || this.$t('falukant.healthview.errors.generic'));
|
||||
}
|
||||
}
|
||||
},
|
||||
handleDaemonMessage(evt) {
|
||||
|
||||
Reference in New Issue
Block a user