Skip to content

Commit

Permalink
feat(Effects): stringify action on invalid action
Browse files Browse the repository at this point in the history
Message before: ERROR Error: Effect "AuthEffects.login$" dispatched an invalid action: [object Object]
Message after: ERROR Error: Effect "AuthEffects.login$" dispatched an invalid action: [{"payload":{"user":{"name":"User"}},"type":"[Auth] Login Success"}]
  • Loading branch information
timdeschryver committed Aug 1, 2018
1 parent afc7fb8 commit 9a95cfc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/effects/src/effect_notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function reportInvalidActions(
new Error(
`Effect ${getEffectName(
output
)} dispatched an invalid action: ${action}`
)} dispatched an invalid action: ${stringify(action)}`
)
);
}
Expand All @@ -57,3 +57,11 @@ function getEffectName({

return `"${sourceName}.${propertyName}${isMethod ? '()' : ''}"`;
}

function stringify(action: any) {
try {
return JSON.stringify(action);
} catch {
return action;
}
}

0 comments on commit 9a95cfc

Please sign in to comment.