From a5c9c0fd6fb235b4baf3110da83f8b6818c912e7 Mon Sep 17 00:00:00 2001 From: Robert Dyer Date: Sat, 28 Feb 2026 12:18:31 -0600 Subject: [PATCH] add extra logging to simplefin setup --- track-investments.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/track-investments.js b/track-investments.js index 80a485b..4502110 100644 --- a/track-investments.js +++ b/track-investments.js @@ -16,16 +16,21 @@ const getCredentials = async () => { const response = await fetch(url, { method: 'post' }); const api_url = await response.text(); - const rest = api_url.split('//', 2)[1]; - const auth = rest.split('@', 1)[0]; - const username = auth.split(':')[0]; - const pw = auth.split(':')[1]; + try { + const rest = api_url.split('//', 2)[1]; + const auth = rest.split('@', 1)[0]; + const username = auth.split(':')[0]; + const pw = auth.split(':')[1]; - const data = `${username}:${pw}`; - const cache = process.env.ACTUAL_CACHE_DIR || './cache'; - fs.writeFileSync(cache + '/simplefin.credentials', data); - console.log('SimpleFIN credentials:', data); - return data; + const data = `${username}:${pw}`; + const cache = process.env.ACTUAL_CACHE_DIR || './cache'; + fs.writeFileSync(cache + '/simplefin.credentials', data); + console.log('SimpleFIN credentials:', data); + return data; + } catch (err) { + console.log('Invalid SimpleFIN setup response:', api_url); + return undefined; + } }; const loadCredentials = () => { @@ -41,6 +46,9 @@ const getSimplefinBalances = async () => { let credentials = loadCredentials(); if (!credentials) { credentials = await getCredentials(); + if (!credentials) { + return undefined; + } } const username = credentials.split(':')[0]; const pw = credentials.split(':')[1];