Git Product home page Git Product logo

Comments (10)

bhb avatar bhb commented on July 22, 2024

Thanks for submitting this! I agree, the output is quite verbose in cases like this. I’ll think more about how I can shorten the output without losing useful context.

from expound.

carocad avatar carocad commented on July 22, 2024

@bhb if I may add. Would it also be possible to add a bit more context to the error report?

In this particular case, :mode "transit" is a key-value pair that is repeated in several steps so the report showing only the failing value is not enough to know exactly which part is failing.

For that I had to switch back to Clojure explain since there I was able to see exactly which values where failing :(

from expound.

bhb avatar bhb commented on July 22, 2024

Thanks for that additional information! Yes, I’ll also look at how to best add more context in this case.

FWIW, if Expound is omitting too much information, you can use “custom-printer” with “:show-valid-values?” set to true. The API is a bit inconsistent right now (I plan to simplify things for the beta) so let me know if you have any trouble getting this working.

from expound.

bhb avatar bhb commented on July 22, 2024

@carocad Here's the code for that:

(binding [s/*explain-out* (expound/custom-printer {:show-valid-values? true})]
  (s/explain (s/coll-of int?) [1 2 :3]))
;;-- Spec failed --------------------
;;
;;  [1 2 :3]
;;       ^^
;;
;;should satisfy
;;
;;  int?
;;
;;-------------------------
;;Detected 1 error

I realize that's not intuitive, but I'll be making this easier at some point. Until then, it may be easiest to wrap it up in a function. Hope that helps!

from expound.

carocad avatar carocad commented on July 22, 2024

@bhb Thanks for the info

Using show-valid-values together with the figwheel-theme do improve the situation a bit. However, now the output is gigantic (due to the size of the response that I have) :(

I think that ideally the failing value should show a bit of the context around (enough to know where the problem is) but not the complete datastructure; otherwise the failing value would get lost among the noise.

I know that is a very hard thing to do, though :/

PS: I avoided pasting the error message here, so please let me know if it would help you somehow

from expound.

bhb avatar bhb commented on July 22, 2024

Yes, it’s a bit tricky. Thanks for letting me know about your use case . It’s very helpful to know which cases need improvement. I’ll think more about this.

from expound.

carocad avatar carocad commented on July 22, 2024

@bhb i just had an idea about how to approach this problem.

Instead of using 'show valid values' I think the concept of depthwould be more appropriate. Basically instead of guessing how much context does a user need to understand the problem, let the user directly tell you.

This is (not by surprise) the same way that most Clojure stacktrace libraries work since those also contain lots of data.

Hope it helps :)

from expound.

bhb avatar bhb commented on July 22, 2024

Ah, that’s a good idea, thanks!

from expound.

kelvinqian00 avatar kelvinqian00 commented on July 22, 2024

I'm also experiencing the same issue as @carocad and my hacked-together solution was simple: capture the printed string from expound/custom-printer with with-out-string, search for empty lines with the following regex:

#"(?<=\n)\s+\.\.\.\n"

and replace each matching string with an empty string. It's a decent solution for my limited use-case, but ideally a similar regex replace would be implemented in the printer itself.

from expound.

bhb avatar bhb commented on July 22, 2024

@kelvinqian00 Thanks for posting this workaround! I agree this is not ideal. I’m thinking about ways to make this behavior optional.

from expound.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.