Improve BoA API error logging and update .gitignore

Read response as text before JSON parsing to capture non-JSON error
responses from BoA API. Add .DS_Store, BofA API Resources, and CSV
files to .gitignore.
This commit is contained in:
Adam Moussa 2026-04-14 20:15:41 -04:00
parent ffd46c4bda
commit c849280705
2 changed files with 7 additions and 2 deletions

3
.gitignore vendored
View file

@ -2,3 +2,6 @@ node_modules/
.aws-sam/
samconfig.toml
data/
.DS_Store
BofA API Resources/
*.csv

View file

@ -223,13 +223,15 @@ export const handler = async (event) => {
}
);
const data = await res.json();
const text = await res.text();
if (!res.ok) {
console.error(`BoA ${action} error ${res.status}:`, JSON.stringify(data));
console.error(`BoA ${action} error ${res.status}:`, text);
throw new Error(`BoA ${action} failed: ${res.status}`);
}
const data = JSON.parse(text);
console.log(
`BoA ${action}: ${data.processedItems}/${data.totalItems} processed, ${data.unprocessedItems} failed`
);