Open deddu opened 8 years ago
+1 This would help me as well
Hey, +1, but I would also like to have an default value for not found keys.
Would it be helpful for you, if I'd provide a patch for this as a pull request?
+1 Would appreciate a fix for this. We had to spend a couple of hours digging into this error. Specifying the key as a part of the error, will be very helpful. Thank you.
If the params._key lookup fails, the message is not really helpful for debugging.
here's a typical error message with stacktrace:
As you can see the stacktrace is not mentioning any file of my project. The reason for this is pretty simple though: is a simple key missing.
Clearly this is happening because the message is undefined.
Let me expose a little more details:
in dust-intl/.../helpers.js in the function formatMessage, there's the following lookup of params._key in the context.
if the key is missing in the context, the value assigned to msg is
undefined
. Which causes a failure later on when callingNaively, I would suggest adding a check and an exception in line 235. I was thinking that a simple check on the value could do it. EG: something trivially simple like
What you think? I'll be glad to submit a pull request if you find that appropriate. This will make debugging my (poor) code dramatically simpler!