Comments (10)
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.
@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.
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.
@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.
@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.
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.
@bhb i just had an idea about how to approach this problem.
Instead of using 'show valid values' I think the concept of depth
would 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.
Ah, that’s a good idea, thanks!
from expound.
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.
@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)
- Error reports returned as :cause string in an exception when produced by instrumentation within generative testing HOT 11
- allow passing options map to expound/expound-str HOT 1
- Improve grouping of spec errors HOT 2
- Unnecessary dependency on `cider-nrepl` HOT 1
- Regression of #3 HOT 4
- Easier editing of error messages
- `printer` has invalid spec HOT 2
- "Cannot convert path" on instrumentation failures in the wild HOT 4
- (cljs.spec.test.alpha/instrument) breaks expound due to wrong arity HOT 4
- should expound work anywhere s/explain works? - clojurescript error HOT 7
- Error in :ret check when using with Orchestra 2020.07.12-1 HOT 5
- Internal error in `lift-singleton-groups` when having a datomic db value in fn args HOT 13
- Crash bug when printing, if a datomic db is present and the spec fails HOT 19
- Feature inquiry: a convenience function for validating a value against a spec HOT 4
- Wrapped `s/keys` does not properly display unqualified keyword specs HOT 5
- ClassCastException from `expound-str` when running in AWS Lambda HOT 9
- Small *print-length* and/or *print-level* sometimes yield NPE HOT 5
- PersistentList cannot be cast to class Named HOT 3
- proposal : defmsg equivalent for arbitrary predicates HOT 15
- optional include location of the spec error in the message. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expound.