File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 36
36
37
37
if (! isSuccess && ! isError ) return ;
38
38
39
- const type = isSuccess ? ' success' : ' error' ;
40
- const message = isSuccess
41
- ? ' CSV import finished successfully.'
42
- : (payload .errors [0 ]?.message ??
43
- ' Import failed. Check your CSV for correct fields and required values.' );
39
+ let errorMessage = ' Import failed. Check your CSV for correct fields and required values.' ;
40
+ if (isError && Array .isArray (payload .errors )) {
41
+ try {
42
+ // the `errors` is a list of json encoded string.
43
+ errorMessage = JSON .parse (payload .errors [0 ]).message ;
44
+ } catch {
45
+ // do nothing, fallback to default message.
46
+ }
47
+ }
44
48
49
+ const type = isSuccess ? ' success' : ' error' ;
50
+ const message = isError ? errorMessage : ' CSV import finished successfully.' ;
45
51
const url = ` ${base }/project-${page .params .region }-${page .params .project }/databases/database-${database }/collection-${collection } ` ;
46
52
47
53
addNotification ({
You can’t perform that action at this time.
0 commit comments