Skip to content

Commit 0570874

Browse files
committed
fix: add error alerts for CSV parsing issues and empty data rows
1 parent 07115d4 commit 0570874

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

custom/ImportCsv.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,20 @@ async function importCsv() {
150150
151151
complete: async (results) => {
152152
if (results.errors.length > 0) {
153+
adminforth.alert({
154+
message: `CSV parsing errors: ${results.errors[0]?.message || 'Unknown error'}`,
155+
variant: 'danger'
156+
});
153157
throw new Error(`CSV parsing errors: ${results.errors.map(e => e.message).join(', ')}`);
154158
}
155159
const data: Record<string, string[]> = {};
156160
const rows = results.data as Record<string, string>[];
157161
158162
if (rows.length === 0) {
163+
adminforth.alert({
164+
message: `No data rows found in CSV`,
165+
variant: 'danger'
166+
});
159167
throw new Error('No data rows found in CSV');
160168
}
161169
Object.keys(rows[0]).forEach(column => {
@@ -172,6 +180,10 @@ async function importCsv() {
172180
inProgress.value = false;
173181
},
174182
error: (error) => {
183+
adminforth.alert({
184+
message: `CSV parsing errors: ${results.errors[0]?.message || 'Unknown error'}`,
185+
variant: 'danger'
186+
});
175187
throw new Error(`Failed to parse CSV: ${error.message}`);
176188
}
177189
});

0 commit comments

Comments
 (0)