From b547747f9f0c626aafdf07d5a3ac25fa3178bbfd Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Wed, 11 Sep 2024 11:38:33 -0400 Subject: [PATCH] Add try/catch to performFetch even though it should already be caught --- src/main/lib/github-interface.ts | 2 +- src/renderer/lib/gitnews-fetcher.ts | 30 +++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/lib/github-interface.ts b/src/main/lib/github-interface.ts index 842f270..49653c0 100644 --- a/src/main/lib/github-interface.ts +++ b/src/main/lib/github-interface.ts @@ -179,7 +179,7 @@ async function getSubjectDataForNotification( subjectHtmlUrl = subject.data.html_url; } catch (error) { logMessage( - `Failed to fetch comment for ${subjectPath} (${notification.subject.url})`, + `Failed to fetch subject for ${subjectPath} (${notification.subject.url})`, 'error' ); } diff --git a/src/renderer/lib/gitnews-fetcher.ts b/src/renderer/lib/gitnews-fetcher.ts index 4600817..6abc3ee 100644 --- a/src/renderer/lib/gitnews-fetcher.ts +++ b/src/renderer/lib/gitnews-fetcher.ts @@ -60,13 +60,20 @@ export function createFetcher(): Middleware<{}, AppReduxState> { 'Accounts changed; fetching with updated accounts', 'info' ); - performFetch( - { - ...store.getState(), - accounts: action.accounts, - }, - next - ); + try { + performFetch( + { + ...store.getState(), + accounts: action.accounts, + }, + next + ); + } catch (err) { + console.error( + 'Got an error fetching which somehow was not caught by the fetch handler', + err + ); + } return next(action); } @@ -74,7 +81,14 @@ export function createFetcher(): Middleware<{}, AppReduxState> { if (action.type === 'GITNEWS_FETCH_NOTIFICATIONS') { debug('Fetching accounts'); window.electronApi.logMessage('Fetching accounts', 'info'); - performFetch(store.getState(), next); + try { + performFetch(store.getState(), next); + } catch (err) { + console.error( + 'Got an error fetching which somehow was not caught by the fetch handler', + err + ); + } return; }