Skip to content

Commit

Permalink
chore: more detailed logging
Browse files Browse the repository at this point in the history
  • Loading branch information
adit-bala committed Nov 26, 2024
1 parent c4b729a commit e4d8e4a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/datapuller/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export async function fetchActiveTerms(
const data = await response.json();
activeTermIds.push(...data.response.terms.map((term: Term) => term.id));
} catch (error: any) {
logger.error(`Unexpected error querying API. Error: "${error}"`);
logger.error(
`Unexpected error querying API for ${term} terms. Error: "${error}"`
);
logger.error(`Error details: ${JSON.stringify(error, null, 2)}`);
if (error.cause) {
logger.error(`Error cause: ${error.cause}`);
}
}
}
const uniqueActiveTermIds = Array.from(new Set(activeTermIds));
Expand Down Expand Up @@ -128,7 +134,6 @@ export async function fetchPaginatedData<T, R>(
return acc;
}, [] as T[]);

// Optionally, log batch errors to the error file
if (batchErrorCount > 0) {
const batchErrorMessage = `${new Date().toISOString()} - Batch error count: ${batchErrorCount}\n`;
await fs.appendFile(errorLogFile, batchErrorMessage);
Expand Down

0 comments on commit e4d8e4a

Please sign in to comment.