Skip to content

Commit 1cc52ef

Browse files
committed
chore: catch specific undefined/ unsuccessful record array data error
1 parent c67fd9b commit 1cc52ef

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

apps/web/src/features/upload/utils.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function generateSampleData({
404404
// eslint-disable-next-line max-depth
405405
if (!inputData?.success) {
406406
console.error({ inputData });
407-
throw new Error(`TODO - handle this case where input data is undefined or not a success`);
407+
throw new Error(`input data is undefined or unsuccessful`);
408408
}
409409
// eslint-disable-next-line max-depth
410410
if (i === multiValues.length - 1 && multiValues[i] !== undefined) {
@@ -415,9 +415,12 @@ function generateSampleData({
415415
}
416416
multiString += ';)';
417417
}
418-
419418
return multiString;
420-
} catch {
419+
} catch (e: unknown) {
420+
if (e instanceof Error && e.message === 'input data is undefined or unsuccessful') {
421+
throw new Error('Unsuccessful input data transfer or undefined data');
422+
}
423+
421424
throw new Error('Invalid Record Array Error');
422425
}
423426
default:
@@ -466,7 +469,10 @@ export function createUploadTemplateCSV(instrument: AnyUnilingualFormInstrument)
466469
content: unparse([csvColumns, sampleData]),
467470
fileName: `${instrument.internal.name}_${instrument.internal.edition}_template.csv`
468471
};
469-
} catch {
472+
} catch (e: unknown) {
473+
if (e instanceof Error && e.message === 'Unsuccessful input data transfer or undefined data') {
474+
throw e;
475+
}
470476
throw new Error('Error generating Sample CSV template');
471477
}
472478
}

0 commit comments

Comments
 (0)