Skip to content

Commit

Permalink
Add more logging to try to determine where the uncaught exception is
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Sep 11, 2024
1 parent b547747 commit 40851fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ipcMain.handle(
// data we actually want. See
// https://github.com/electron/electron/issues/24427
logMessage(
`Failure while fetching notifications for account ${account.name}(${account.serverUrl})`,
`Failure while fetching notifications for account ${account.name} (${account.serverUrl})`,
'error'
);
return {
Expand Down
26 changes: 22 additions & 4 deletions src/renderer/lib/gitnews-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export function createFetcher(): Middleware<{}, AppReduxState> {
next
);
} catch (err) {
window.electronApi.logMessage(
'Got an error fetching which somehow was not caught by the fetch handler',
'error'
);
console.error(
'Got an error fetching which somehow was not caught by the fetch handler',
err
Expand All @@ -84,6 +88,10 @@ export function createFetcher(): Middleware<{}, AppReduxState> {
try {
performFetch(store.getState(), next);
} catch (err) {
window.electronApi.logMessage(
'Got an error fetching which somehow was not caught by the fetch handler',
'error'
);
console.error(
'Got an error fetching which somehow was not caught by the fetch handler',
err
Expand Down Expand Up @@ -128,8 +136,11 @@ export function createFetcher(): Middleware<{}, AppReduxState> {
// or the app will get stuck never updating again.
next(fetchBegin());

const getGithubNotifications = getFetcher(state.accounts, state.isDemoMode);
try {
const getGithubNotifications = getFetcher(
state.accounts,
state.isDemoMode
);
const notes = await getGithubNotifications();
debug('notifications retrieved', notes);
window.electronApi.logMessage(
Expand Down Expand Up @@ -167,21 +178,28 @@ export function createFetcher(): Middleware<{}, AppReduxState> {
`Fetching notifications for ${account.name} (${account.serverUrl})`,
'info'
);
const promise = fetchNotifications(account);
promises.push(promise);
promise
const promise = fetchNotifications(account)
.then((notes) => {
if ('error' in notes) {
throw notes.error;
}
allNotes = [...allNotes, ...notes];
})
.catch((err) => {
window.electronApi.logMessage(
`Fetching notifications FAILED for ${account.name} (${account.serverUrl})`,
'error'
);
throw err;
});
promises.push(promise);
}

await Promise.all(promises).catch((err) => {
window.electronApi.logMessage(
`Waiting for fetched notifications FAILED`,
'error'
);
throw err;
});

Expand Down

0 comments on commit 40851fd

Please sign in to comment.