ViacomInc / data-point

JavaScript Utility for collecting, processing and transforming data
Apache License 2.0
67 stars 34 forks source link

Improve reducer factory error message #225

Open raingerber opened 6 years ago

raingerber commented 6 years ago

Problem description:

Strings are only valid reducers when they start with $, but the error message is confusing when you try to resolve an invalid string:

dataPoint.resolve('invalid', {})
Unhandled rejection Error: Invalid reducer type. Could not find a matching reducer type while parsing the value:
 'invalid'
Try using an Array, String, Object, or Function.

It's confusing because the input was as a string, but the error says "Try using a string."

Suggested solution:

Rephrase the error message to something like this:

Try using an Array, Object, Function, or String beginning with "$".

https://github.com/ViacomInc/data-point/blob/master/packages/data-point/lib/reducer-types/factory.js#L59

EDIT: we also use strings with the format <entityType>:<entityId>

victorsingh commented 6 years ago

Will take this one 👍