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

Conversation

Kristjansson
Copy link
Contributor

When logging the value, it's not always clear the exact type that's causing failure (ArrayList vs vec for example). Adding the type makes this error message a little more informative.

@codecov-io
Copy link

Codecov Report

Merging #15 into master will decrease coverage by 1.8%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #15      +/-   ##
==========================================
- Coverage     100%   98.19%   -1.81%     
==========================================
  Files          13       13              
  Lines         811      831      +20     
  Branches        0        4       +4     
==========================================
+ Hits          811      816       +5     
- Misses          0       11      +11     
- Partials        0        4       +4
Impacted Files Coverage Δ
src/clj_cbor/codec.clj 100% <100%> (ø) ⬆️
src/clj_cbor/data/simple.clj 28.57% <0%> (-71.43%) ⬇️
src/clj_cbor/data/tagged.clj 50% <0%> (-50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 875784b...b1af7fc. Read the comment docs.

@greglook greglook self-assigned this Oct 8, 2019
Copy link
Owner

@greglook greglook left a comment

Choose a reason for hiding this comment

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

Seems like a useful addition to the error case - could you also cover this with a test?

@@ -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.

Copy link
Owner

@greglook greglook left a comment

Choose a reason for hiding this comment

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

Going to merge this so you have a commit, will make the change I suggested directly.

@greglook greglook merged commit d9ec37d into greglook:master Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants