From 9a95cfc4842f84578d2777b1cb5be70d15de6ea4 Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Wed, 1 Aug 2018 12:50:03 +0200 Subject: [PATCH] feat(Effects): stringify action on invalid action 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"}] --- modules/effects/src/effect_notification.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/effects/src/effect_notification.ts b/modules/effects/src/effect_notification.ts index 1d33bab58f..21954d74a3 100644 --- a/modules/effects/src/effect_notification.ts +++ b/modules/effects/src/effect_notification.ts @@ -37,7 +37,7 @@ function reportInvalidActions( new Error( `Effect ${getEffectName( output - )} dispatched an invalid action: ${action}` + )} dispatched an invalid action: ${stringify(action)}` ) ); } @@ -57,3 +57,11 @@ function getEffectName({ return `"${sourceName}.${propertyName}${isMethod ? '()' : ''}"`; } + +function stringify(action: any) { + try { + return JSON.stringify(action); + } catch { + return action; + } +}