Skip to content

Commit 3a03b26

Browse files
authored
Merge pull request #9 from devforth/error-handling-for-incorrect-import
fix: add error alerts for CSV parsing issues and empty data rows
2 parents 07115d4 + f527710 commit 3a03b26

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

custom/ImportCsv.vue

+12
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 at row ${results.errors[0]?.row + 1 || '?'}: ${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: ${error.message}}`,
185+
variant: 'danger'
186+
});
175187
throw new Error(`Failed to parse CSV: ${error.message}`);
176188
}
177189
});

0 commit comments

Comments
 (0)