Skip to content

A local-first personal finance app

Show better error if SimpleFIN account cant be found. (#412)

Robert Dyerb74f0f298273
diff --git a/src/app-simplefin/app-simplefin.js b/src/app-simplefin/app-simplefin.js
index 31d10439c3..dd37ee8c52 100644
--- a/src/app-simplefin/app-simplefin.js
+++ b/src/app-simplefin/app-simplefin.js
@@ -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`,
diff --git a/upcoming-release-notes/412.md b/upcoming-release-notes/412.md
new file mode 100644
index 0000000000..b8c2f4a581
--- /dev/null
+++ b/upcoming-release-notes/412.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [psybers]
+---
+
+Show better error if SimpleFIN account cant be found.