Skip to content

Commit f9f3f1e

Browse files
committed
Addressing Julia's comments on uncaught promise rejections in validation
1 parent 47d0526 commit f9f3f1e

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/client/BaseClient.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,23 @@ class BaseClient {
4343
// Using Reduce to compute the validity of all extractors
4444
const allExtractorsValid = await this.extractors.reduce(async (curExtractorsValid, curExtractor) => {
4545
const { name } = curExtractor.constructor;
46-
4746
if (curExtractor.validate) {
4847
logger.debug(`Validating ${name}`);
49-
const isExtractorValid = await curExtractor.validate();
50-
if (isExtractorValid) {
51-
logger.debug(`Extractor ${name} PASSED CSV validation`);
52-
} else {
48+
try {
49+
const isExtractorValid = await curExtractor.validate();
50+
if (isExtractorValid) {
51+
logger.debug(`Extractor ${name} PASSED CSV validation`);
52+
} else {
53+
logger.warn(`Extractor ${name} FAILED CSV validation`);
54+
}
55+
return ((await curExtractorsValid) && isExtractorValid);
56+
} catch (e) {
5357
logger.warn(`Extractor ${name} FAILED CSV validation`);
58+
return false;
5459
}
55-
return (curExtractorsValid && isExtractorValid);
5660
}
5761
return curExtractorsValid;
58-
}, true);
62+
}, Promise.resolve(true));
5963

6064
if (allExtractorsValid) {
6165
logger.info('Validation succeeded');

src/modules/CSVURLModule.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CSVURLModule {
2020
const csvData = await axios.get(this.url)
2121
.then((res) => res.data)
2222
.catch((e) => {
23-
logger.error('Error occurred when getting CSV data using url');
23+
logger.error('Error occurred when making a connection to this url');
2424
throw e;
2525
});
2626
logger.debug('Web request successful');
@@ -29,7 +29,7 @@ class CSVURLModule {
2929
columns: (header) => header.map((column) => stringNormalizer(column)),
3030
bom: true,
3131
});
32-
logger.debug('Data parsing successful');
32+
logger.debug('CSV Data parsing successful');
3333
this.data = normalizeEmptyValues(parsedData, this.unalterableColumns);
3434
}
3535
}

0 commit comments

Comments
 (0)