You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rec2json cannot convert a term to a json representation, it throws a exception of type {badarg, field_name(), field_value(), field_types()}. This is correct as far as adhering to erlang error output structure, but ends up writing something like the following to the console:
** exception error: bad argument:
{products,
[{product,undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,
undefined,undefined}],
{specific,
[undefined,
{list,{specific,[{product,product,[]}]}}]}}
in function rec2json:'-to_json/2-fun-1-'/3 (src/rec2json.erl, line 145)
in call from lists:foldl/3 (lists.erl, line 1262)
in call from rec2json:to_json/2 (src/rec2json.erl, line 135)
Sure, if you stare at that and the rec2json source code, or you know the rec2json error format above, it's slightly helpful, otherwise it's a mismash of wtf. Often, when this happens, it is not meant to be handled and recovered, but fixed by a developer. This means developer understanding of the error is more important that efficient consumption by a computer. Given that, the format should change:
When
rec2json
cannot convert a term to a json representation, it throws a exception of type{badarg, field_name(), field_value(), field_types()}
. This is correct as far as adhering to erlang error output structure, but ends up writing something like the following to the console:Sure, if you stare at that and the rec2json source code, or you know the rec2json error format above, it's slightly helpful, otherwise it's a mismash of wtf. Often, when this happens, it is not meant to be handled and recovered, but fixed by a developer. This means developer understanding of the error is more important that efficient consumption by a computer. Given that, the format should change:
With a completely faked error, the console output becomes:
Use of a map because it looks nicer than a prophets, though if pre-18 is required, that can be waved.
The text was updated successfully, but these errors were encountered: