From 35031e3ae5425f25b608e940767b1e5a98bb5081 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 17 Jul 2026 13:48:56 +0200 Subject: [PATCH] fix: improve error handling for CSV import in upload and ScheduleView --- backend/controllers/matchController.js | 4 +++- frontend/src/views/ScheduleView.vue | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/controllers/matchController.js b/backend/controllers/matchController.js index b3e5fef1..10a47b35 100755 --- a/backend/controllers/matchController.js +++ b/backend/controllers/matchController.js @@ -16,7 +16,9 @@ export const uploadCSV = async (req, res) => { }); } catch (error) { console.error('Error importing CSV:', error); - return res.status(500).json({ error: 'Failed to import CSV data' }); + return res.status(500).json({ + error: error.message || 'Failed to import CSV data' + }); } }; diff --git a/frontend/src/views/ScheduleView.vue b/frontend/src/views/ScheduleView.vue index c1915813..139775d5 100755 --- a/frontend/src/views/ScheduleView.vue +++ b/frontend/src/views/ScheduleView.vue @@ -2206,16 +2206,24 @@ export default { formData.append('clubId', this.currentClub); try { - await apiClient.post('/matches/import', formData, { + const response = await apiClient.post('/matches/import', formData, { headers: { 'Content-Type': 'multipart/form-data' } }); + if (response.status < 200 || response.status >= 300) { + throw new Error(response.data?.error || 'Failed to import CSV data'); + } this.showInfo(this.$t('messages.success'), this.$t('schedule.scheduleImportSuccess'), '', 'success'); this.closeImportModal(); this.loadTeams(); } catch (error) { - this.showInfo(this.$t('messages.error'), this.$t('schedule.errorImportingCSV'), '', 'error'); + this.showInfo( + this.$t('messages.error'), + getSafeErrorMessage(error, this.$t('schedule.errorImportingCSV')), + '', + 'error' + ); } }, // Sortierfunktion für Ligen