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

Exception no longer mentions source? (:args, :ret) #51

Open
Frozenlock opened this issue Jul 23, 2020 · 5 comments
Open

Exception no longer mentions source? (:args, :ret) #51

Frozenlock opened this issue Jul 23, 2020 · 5 comments

Comments

@Frozenlock
Copy link

With the new version there doesn't seem to be a way to know from where the failure originates.
(Bad arguments or bad return value?)

@jeaye
Copy link
Owner

jeaye commented Jul 23, 2020

Hey! Thanks for using Orchestra. The information is available, if we look into the exception data thrown. Here is the exception data from Orchestra's own test suite.

Failure in return check

{:clojure.spec.alpha/problems [{:path []
                                :pred clojure.core/integer?
                                :val true
                                :via []
                                :in []}]
 :clojure.spec.alpha/spec #object[clojure.spec.alpha$spec_impl$reify__2069 0x5d92bd50 "clojure.spec.alpha$spec_impl$reify__2069@5d92bd50"]
 :clojure.spec.alpha/value true
 :clojure.spec.alpha/fn orchestra.core-test/ret'
 :clojure.spec.alpha/ret true
 :clojure.spec.alpha/failure :instrument
 :orchestra.spec.test/caller {:file "core_test.cljc"
                              :line 35
                              :var-scope orchestra.core-test/fn--21819}}

Failure in arg check

{:clojure.spec.alpha/problems [{:path [:meow]
                                :pred clojure.core/string?
                                :val 42
                                :via []
                                :in [0]}]
 :clojure.spec.alpha/spec #object[clojure.spec.alpha$regex_spec_impl$reify__2519 0x50a7c4c4 "clojure.spec.alpha$regex_spec_impl$reify__2519@50a7c4c4"]
 :clojure.spec.alpha/value (42)
 :clojure.spec.alpha/fn orchestra.core-test/args'
 :clojure.spec.alpha/args (42)
 :clojure.spec.alpha/failure :instrument
 :orchestra.spec.test/caller {:file "core_test.cljc"
                              :line 24
                              :var-scope orchestra.core-test/fn--30314}}

So, if :clojure.spec.alpha/args is present, it's an argument failure. If :clojure.spec.alpha/ret is present, it's a return failure.

However, while you can use this data, for most people I highly recommend just using Expound to format your spec failures. Orchestra is tested specifically to work with Expound.

@Frozenlock
Copy link
Author

Ah I see, I will give Expound a try.
Thank you very much!

@jeaye
Copy link
Owner

jeaye commented Jul 24, 2020

Sure thing. Happy hacking.

@Frozenlock
Copy link
Author

I gave Expound a try and IMO it's not as good as handy as the information in the exception message.
Would you be open to having different messages?
"Call to 'fn-name' did not conform to spec..."
"Return value from 'fn-name' did not conform to spec..."

@jeaye
Copy link
Owner

jeaye commented Aug 1, 2020

Hm, I see where you're coming from. I would be open to this, if we distinguish:

  1. :args failures
  2. :ret failures
  3. :fn failures

and if it still works properly with Expound.

I'll reopen this ticket to keep this task on the books.

@jeaye jeaye reopened this Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants