Skip to content

Commit

Permalink
chore: add more descriptive errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Valdermeyder committed Feb 4, 2024
1 parent d5f5b32 commit 81b6ea3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ app.post("/", ({ files, body: { bank } }, response) => {
.on("error", getHttpErrorHandler(response))
.pipe(response);
} catch (err) {
response.status(500).send(err);
console.error('Unexpected error is occured', err)
response.status(500);
}
} else {
response.status(400).send("No file was uploaded.");
Expand Down
3 changes: 3 additions & 0 deletions mappingNormalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ exports.normalizeCategories = (categories) => categories && Object.keys(categori
const category = categories[categoryKey];
return Object.keys(category).reduce((subCategoriesWithPayers, subCategoryKey) => {
const payers = category[subCategoryKey] || []
if (!Array.isArray(payers)) {
throw new Error(`Payers for "${subCategoryKey}" is not an array`)
}
return payers.reduce((payersWithSubCategory, payer) =>
({ ...payersWithSubCategory, [payer]: { category: categoryKey, subCategory: subCategoryKey } }), subCategoriesWithPayers)
}, payerByCategory)
Expand Down

0 comments on commit 81b6ea3

Please sign in to comment.