Refactor error handling in FalukantService and enhance user feedback in HealthView
- Changed error throwing in FalukantService to use PreconditionError for better clarity. - Added translations for "too close" error in both German and English locales. - Improved user feedback in HealthView by displaying error messages in a dialog upon measure execution failure.
This commit is contained in:
@@ -129,13 +129,22 @@ export default {
|
||||
async performMeasure() {
|
||||
if (!this.selectedMeasure) return;
|
||||
try {
|
||||
await apiClient.post('/api/falukant/health', {
|
||||
const { data } = await apiClient.post('/api/falukant/health', {
|
||||
measureTr: this.selectedTr
|
||||
});
|
||||
// Feedback via global message dialog
|
||||
const title = this.$t('falukant.healthview.title');
|
||||
const body = data?.delta != null
|
||||
? `${this.$t(`falukant.healthview.measures.${this.selectedTr}`)}: ${data.delta > 0 ? '+' : ''}${data.delta}`
|
||||
: this.$t('message.success');
|
||||
this.$root.$refs.messageDialog?.open(body, title);
|
||||
await this.loadHealthData();
|
||||
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);
|
||||
}
|
||||
},
|
||||
handleDaemonMessage(evt) {
|
||||
|
||||
Reference in New Issue
Block a user