Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report type when erroring on unsupported-type #15

Merged
merged 2 commits into from
Apr 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/clj_cbor/codec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@
(error/*handler*
::unsupported-type
(str "No known encoding for object: " (pr-str x))
{:value x})))
{:value x
:type (type x)})))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two thoughts here - first, class is generally more appropriate than type, since the latter will return you (:type (meta x)) which is (obviously) user-modifiable. Given that the default dispatch function is class this would also match the behavior better.

Second thought builds on the first one, which is that this case occurs when write-handled falls through because there's no handler for the dispatched type. It may be more useful to make this data include the dispatch function's return value, since that's what's actually used for the handler behavior.



Decoder
Expand Down