diff --git a/src/renderer/lib/config-middleware.ts b/src/renderer/lib/config-middleware.ts index 9143f8a..f4db434 100644 --- a/src/renderer/lib/config-middleware.ts +++ b/src/renderer/lib/config-middleware.ts @@ -5,7 +5,9 @@ import { isAction } from './helpers'; export const configMiddleware: Middleware<{}, AppReduxState> = (_store) => (next) => (action) => { if (!isAction(action)) { - throw new Error('Invalid action dispatched'); + throw new Error( + 'Invalid action dispatched in config: ' + JSON.stringify(action) + ); } switch (action.type) { case 'SET_INITIAL_TOKEN': diff --git a/src/renderer/lib/electron-middleware.ts b/src/renderer/lib/electron-middleware.ts index 291aa40..394ee68 100644 --- a/src/renderer/lib/electron-middleware.ts +++ b/src/renderer/lib/electron-middleware.ts @@ -17,7 +17,9 @@ function scrollToTopNotification() { export const electronMiddleware: Middleware<{}, AppReduxState> = (_store) => (next) => (action) => { if (!isAction(action)) { - throw new Error('Invalid action dispatched'); + throw new Error( + 'Invalid action dispatched in electron: ' + JSON.stringify(action) + ); } switch (action.type) { case 'OPEN_URL': diff --git a/src/renderer/lib/github-middleware.ts b/src/renderer/lib/github-middleware.ts index 787027e..cfaa053 100644 --- a/src/renderer/lib/github-middleware.ts +++ b/src/renderer/lib/github-middleware.ts @@ -13,7 +13,10 @@ export function createGitHubMiddleware(): Middleware<{}, AppReduxState> { return (store) => (next) => (action) => { if (!isAction(action)) { - throw new Error('Invalid action dispatched'); + throw new Error( + 'Invalid action dispatched in github controls: ' + + JSON.stringify(action) + ); } switch (action.type) { case 'MARK_NOTE_READ': { diff --git a/src/renderer/lib/gitnews-fetcher.ts b/src/renderer/lib/gitnews-fetcher.ts index b028b3f..7006e36 100644 --- a/src/renderer/lib/gitnews-fetcher.ts +++ b/src/renderer/lib/gitnews-fetcher.ts @@ -30,8 +30,13 @@ let currentDemoNotifications = createDemoNotifications(); export function createFetcher(): Middleware<{}, AppReduxState> { const fetcher: Middleware = (store) => (next) => (action) => { - if (!isAction(action) || !isDispatch(next)) { - throw new Error('Invalid action dispatched'); + if (!isAction(action)) { + throw new Error( + 'Invalid action dispatched in fetcher: ' + JSON.stringify(action) + ); + } + if (!isDispatch(next)) { + throw new Error('Invalid dispatcher in fetcher'); } if (action.type === 'MARK_NOTE_READ' && store.getState().isDemoMode) { currentDemoNotifications = currentDemoNotifications.map((note) => { diff --git a/src/renderer/lib/helpers.ts b/src/renderer/lib/helpers.ts index f9f85a5..3cd78c4 100644 --- a/src/renderer/lib/helpers.ts +++ b/src/renderer/lib/helpers.ts @@ -109,7 +109,7 @@ export function getSecondsUntilNextFetch( export function isAction(action: unknown): action is AppReduxAction { const typedAction = action as AppReduxAction; - if (!('type' in typedAction) || !('token' in typedAction)) { + if (!('type' in typedAction)) { return false; } return true;