Skip to content

Commit

Permalink
fix: Stop errors getting swallowed by the multibar
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk committed Nov 8, 2024
1 parent ea198cb commit 9110ae7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/harvest-rpde.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ async function baseHarvestRPDE({
const responseTime = timerEnd - timerStart;

if (!response.data || typeof response.data !== 'object' || !response.data.lowFidelityData || typeof response.data.lowFidelityData !== 'object') {
logError(`\nFATAL ERROR: RPDE feed ${feedContextIdentifier} page "${url}" with response code ${response.status} is not valid JSON:\n\nResponse: ${response.data}`);
if (multibar) multibar.stop();
logErrorDuringHarvest(`\nFATAL ERROR: RPDE feed ${feedContextIdentifier} page "${url}" with response code ${response.status} is not valid JSON:\n\nResponse: ${response.data}`);
// TODO: Provide context to the error callback
onError();
return;
Expand All @@ -114,7 +115,7 @@ async function baseHarvestRPDE({

if (rpdeValidationErrors.length > 0) {
if (multibar) multibar.stop();
logError(`\nFATAL ERROR: RPDE Validation Error(s) found on RPDE feed ${feedContextIdentifier} page "${url}":\n${rpdeValidationErrors.map(error => `- ${error.message.split('\n')[0]}`).join('\n')}\n`);
logErrorDuringHarvest(`\nFATAL ERROR: RPDE Validation Error(s) found on RPDE feed ${feedContextIdentifier} page "${url}":\n${rpdeValidationErrors.map(error => `- ${error.message.split('\n')[0]}`).join('\n')}\n`);
// TODO: Provide context to the error callback
onError();
return;
Expand Down Expand Up @@ -183,7 +184,7 @@ async function baseHarvestRPDE({
if (error.name === 'FatalError') {
// If a fatal error, quit the application immediately
if (multibar) multibar.stop();
logError(`\nFATAL ERROR for RPDE feed ${feedContextIdentifier} page "${url}": ${error.message}\n`);
logErrorDuringHarvest(`\nFATAL ERROR for RPDE feed ${feedContextIdentifier} page "${url}": ${error.message}\n`);
// TODO: Provide context to the error callback
onError();
return;
Expand Down Expand Up @@ -212,7 +213,7 @@ async function baseHarvestRPDE({
await sleep(5000);
} else {
if (multibar) multibar.stop();
logError(`\nFATAL ERROR: Retry limit exceeded for RPDE feed ${feedContextIdentifier} page "${url}"\n`);
logErrorDuringHarvest(`\nFATAL ERROR: Retry limit exceeded for RPDE feed ${feedContextIdentifier} page "${url}"\n`);
// TODO: Provide context to the error callback
onError();
return;
Expand Down

0 comments on commit 9110ae7

Please sign in to comment.