Feature: Show error in webapp if pin_mapping.json contains syntax errors

This commit is contained in:
Thomas Basler 2023-07-22 15:51:16 +02:00
parent 972dea297b
commit eaacce7483
5 changed files with 14 additions and 6 deletions

View File

@ -527,6 +527,7 @@
}, },
"deviceadmin": { "deviceadmin": {
"DeviceManager": "Hardware-Einstellungen", "DeviceManager": "Hardware-Einstellungen",
"ParseError": "Syntaxfehler in 'pin_mapping.json': {error}",
"PinAssignment": "Anschlusseinstellungen", "PinAssignment": "Anschlusseinstellungen",
"SelectedProfile": "Ausgewähltes Profil:", "SelectedProfile": "Ausgewähltes Profil:",
"DefaultProfile": "(Standardeinstellungen)", "DefaultProfile": "(Standardeinstellungen)",

View File

@ -527,6 +527,7 @@
}, },
"deviceadmin": { "deviceadmin": {
"DeviceManager": "Device-Manager", "DeviceManager": "Device-Manager",
"ParseError": "Parse error in 'pin_mapping.json': {error}",
"PinAssignment": "Connection settings", "PinAssignment": "Connection settings",
"SelectedProfile": "Selected profile:", "SelectedProfile": "Selected profile:",
"DefaultProfile": "(Default settings)", "DefaultProfile": "(Default settings)",

View File

@ -527,6 +527,7 @@
}, },
"deviceadmin": { "deviceadmin": {
"DeviceManager": "Gestionnaire de périphériques", "DeviceManager": "Gestionnaire de périphériques",
"ParseError": "Erreur d'analyse dans 'pin_mapping.json': {error}",
"PinAssignment": "Paramètres de connexion", "PinAssignment": "Paramètres de connexion",
"SelectedProfile": "Profil sélectionné", "SelectedProfile": "Profil sélectionné",
"DefaultProfile": "(Réglages par défaut)", "DefaultProfile": "(Réglages par défaut)",

View File

@ -76,7 +76,7 @@ export function handleResponse(response: Response, emitter: Emitter<Record<Event
router.push({ path: "/login", query: { returnUrl: router.currentRoute.value.fullPath } }); router.push({ path: "/login", query: { returnUrl: router.currentRoute.value.fullPath } });
} }
const error = (data && data.message) || response.statusText; const error = { message: (data && data.message) || response.statusText, status: response.status || 0 };
return Promise.reject(error); return Promise.reject(error);
} }

View File

@ -157,7 +157,12 @@ export default defineComponent({
this.pinMappingList = data; this.pinMappingList = data;
} }
) )
.catch(() => { .catch((error) => {
if (error.status != 404) {
this.alertMessage = this.$t('deviceadmin.ParseError', { error: error.message });
this.alertType = 'danger';
this.showAlert = true;
}
this.pinMappingList = Array<Device>(); this.pinMappingList = Array<Device>();
}) })
.finally(() => { .finally(() => {