Skip to content

Commit

Permalink
Show better error if SimpleFIN account cant be found. (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
psybers authored Aug 8, 2024
1 parent 12f4295 commit b74f0f2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/app-simplefin/app-simplefin.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,27 @@ app.post(
}

try {
const account = results.accounts.find((a) => a.id === accountId);
const account =
!results?.accounts || results.accounts.find((a) => a.id === accountId);
if (!account) {
console.log(
`The account "${accountId}" was not found. Here were the accounts returned:`,
);
if (results?.accounts)
results.accounts.forEach((a) =>
console.log(`${a.id} - ${a.org.name}`),
);
res.send({
status: 'ok',
data: {
error_type: 'ACCOUNT_MISSING',
error_code: 'ACCOUNT_MISSING',
status: 'rejected',
reason: `The account "${accountId}" was not found. Try unlinking and relinking the account.`,
},
});
return;
}

const needsAttention = results.errors.find(
(e) => e === `Connection to ${account.org.name} may need attention`,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/412.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [psybers]
---

Show better error if SimpleFIN account cant be found.

0 comments on commit b74f0f2

Please sign in to comment.