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

Errors with large data structures became harder to read #108

Open
oakes opened this issue Jul 2, 2018 · 1 comment
Open

Errors with large data structures became harder to read #108

oakes opened this issue Jul 2, 2018 · 1 comment

Comments

@oakes
Copy link

oakes commented Jul 2, 2018

I use expound in edna and I noticed that errors in 0.7.1 were harder to read than in 0.7.0 when they occur inside a large outer data structure. In 0.7.0, it points to the specific part of the data structure first:

Exception in thread "main" java.lang.Exception: -- Syntax error -------------------

  [...
   [:guitarx
    ^^^^^^^^
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...]
<snip>

In 0.7.1, it prints the entire data structure first, and you have to scroll (sometimes far) down to see it eventually point to the specific part of the data structure where the error is:

Exception in thread "main" java.lang.Exception: -- Spec failed --------------------

  [{:tempo 80}
   [:guitarx {:octave 3} 1/16 :b :+c 1/8 :+d :b :+c :a :b :g :a]
   [:banjo {:octave 3} 1/16 :b :+c 1/8 :+d :b :+c :a :b :g :a]
   [:guitar {:octave 3} 1/16 :b :+c 1/8 :+d :b :+c :a :b :g :a]
   [:guitar {:octave 3} 1/2 :d 1/8 :g :g :a :b :g :b 1/2 :a]
   [:banjo {:octave 3} 1/8 :g :g :a :b 1/2 :g]
   [:guitar {:octave 2} 1/16 :g :g 1/8 :g :a :b :+c :+d :+c 1/2 :b]
   [:banjo {:octave 3} 1/16 :g :g 1/8 :g :a :b :+c :+d :+c 1/2 :b]
   [:guitar {:octave 2} 1/16 :g :g 1/8 :g :a :b :+c :+d :+c 1/2 :b]
   [:banjo {:octave 3} 1/16 :g :g 1/8 :g :a :b :+c :+d :+c 1/2 :b]
   [:guitar {:octave 3} 1/16 :g :g 1/8 :g :a :b :+c :+d :+c 1/2 :b]
   [:banjo {:octave 3} 1/16 :g :g 1/8 :g :a :b :+c :+d :+c 1/2 :b]
   [:guitar
    {:octave 4}
    1/16
    #{:-g :-b :d}
    #{:-g :-b :d}
<snip>
-- Spec failed --------------------

  [...
   [:guitarx {:octave 3} 1/16 :b :+c 1/8 :+d :b :+c :a :b :g :a]
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ...
   ...
   ...
   ...
   ...
   ...
   ...
   ...
<snip>
-- Syntax error -------------------

  [...
   [:guitarx
    ^^^^^^^^
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...
    ...]
<snip>

I posted a code example and the output of both versions here https://gist.github.com/oakes/dbc902e8fb077d6430fa0909cf4d7272

@bhb
Copy link
Owner

bhb commented Jul 3, 2018

Thanks for reporting this! In 0.7.0, some relevant errors were omitted when there were multiple ways to fix the value (which occurred in macro specs which had many ‘or’ or ‘alt’ specs) so in 0.7.1, I changed the code to show every problem.

However, I agree this choice is quite verbose in this case where only the inner spec is relevant. I’ll think more about how to do the best thing in both cases.

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