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 Location information is wrong #37

Closed
Vampire opened this issue Aug 25, 2020 · 4 comments
Closed

Exception Location information is wrong #37

Vampire opened this issue Aug 25, 2020 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Vampire
Copy link

Vampire commented Aug 25, 2020

I just got a parse error at Exception Location: Location(line=243, column=23) saying Value for 'distribution1' is invalid: Expected a string, but got a map.
But in my input file at 243:23 there is no distribution1 key.
The earliest is at line 557.

Actually at 243:23 I define an anchor for a map.
And then further down e. g. at 557 for distribution1 I use that anchor.
So the line information is showing the referenced to line instead of the referencing line which makes it a bit harder to find the actual problem, as you don't know which referencing line causes a parsing error.

@charleskorn
Copy link
Owner

Hey @Vampire, thanks for the feedback. Are you able to share a simple sample YAML file that demonstrates the problem? It would be helpful to be able to reproduce the issue you're seeing so that I can confirm that I've fixed the problem.

@charleskorn charleskorn added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Aug 25, 2020
@Vampire
Copy link
Author

Vampire commented Aug 25, 2020

Sure:
input file:

bar:
    - &baz
      bam: boo

foo: *baz

DAO:

@Serializable
data class Foo(
        val bar: List<Map<String, String>>,
        val foo: String
)

Result:

Exception Location: Location(line=2, column=7)
Value for 'foo' is invalid: Expected a string, but got a map

2:7 is the & character

@charleskorn
Copy link
Owner

Just to keep you updated - this is not straightforward to fix, so I'm not going to be able to fix it soon. I'll keep the issue open until I have a chance to take a look at this.

charleskorn added a commit that referenced this issue Sep 27, 2020
This describes the path taken to get to a node and will be helpful
for resolving the issue described in #37.
charleskorn added a commit that referenced this issue Sep 30, 2020
This will make it much easier to show more detailed error messages.

See #37.
@charleskorn
Copy link
Owner

This has been fixed, and will be part of the next release.

Exceptions now have the concept of a path, which shows the path taken to get to the location of the error. For example foo.bar, or in the case of the error above, foo->&baz. Exception messages now include the path in toString(), and for more advanced use cases, you can inspect the path property to see the location (line and column) of each segment of the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants