Closed chengjianhua closed 5 years ago
Hmm, yes I'd agree. Error messages are rather cryptic in serializr. It would be good to improve the error messages across the board. Unfortunately, the way the invariant function works, it would require changing all the invariant calls to JSON.stringify
the value before logging it. Let me do some investigation over the next day or two to see if I can improve the logging in a simpler way.
@alexggordon Do you come up with a good idea about this ?
@alexggordon
We can brow the idea of debug
which was used to output readable log message includes object and some other non-primitive data.
Implementing a simple utility that supports syntax like below:
invariant(
false,
'This is a object %o',
{ x: 1, y: 1 },
);
closed with #68
the stack trace:
https://github.com/mobxjs/serializr/blob/master/src/types/primitive.js#L20
https://github.com/mobxjs/serializr/blob/master/src/utils/utils.js#L19
Can we
JSON.stringify()
or just place an statementconsole.log(nonPrimitiveValue)
beforeinvariant()
throwing an error ?Or is there any better solutions ? @alexggordon