Skip to content

Commit

Permalink
Add try/catch to performFetch even though it should already be caught
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Sep 11, 2024
1 parent f57b542 commit b547747
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/lib/github-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
Expand Down
30 changes: 22 additions & 8 deletions src/renderer/lib/gitnews-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,35 @@ 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);
}

// FIXME: why does this trigger so many times during a fetch?
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;
}

Expand Down

0 comments on commit b547747

Please sign in to comment.