Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Effects): stringify action on invalid action #1219

Merged

Conversation

timdeschryver
Copy link
Member

To have a more meaningful error when the effects retrieve an invalid action we could stringify the action. That way the dev would immediately know which action is wrong, this could be helpful for newcomers.

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"}]

@coveralls
Copy link

coveralls commented Aug 1, 2018

Coverage Status

Coverage increased (+0.009%) to 88.618% when pulling 8d322d9 on timdeschryver:pr/effects-stringify-action into afc7fb8 on ngrx:master.

@@ -57,3 +57,11 @@ function getEffectName({

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

function stringify(action: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type to Action | null | undefined and add a test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Busted 😅

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"}]
@timdeschryver timdeschryver force-pushed the pr/effects-stringify-action branch from 9a95cfc to 8d322d9 Compare August 1, 2018 17:34
@brandonroberts brandonroberts merged commit 73d32eb into ngrx:master Aug 1, 2018
@timdeschryver timdeschryver deleted the pr/effects-stringify-action branch August 1, 2018 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants