What line number was it?

318 views
Skip to first unread message

Niels Basjes

unread,
Mar 27, 2017, 3:20:06 PM3/27/17
to SnakeYAML
Hi,

In my application ( https://github.com/nielsbasjes/yauaa ) I read multiple Yaml files.
The settings found in those files are evaluated at startup and in some cases an error occurs in one of those settings.
Now from the yaml perspective these files are correct, yet from the perspective of my application they are not. 

What I would like is to show along with the filename also the line number where the error occurred. 
I have not found any reference to the line number in any of the datastructures that I get.
So perhaps you guys can advise me on how to handle this?

Thanks

Niels Basjes

Andrey Somov

unread,
Mar 28, 2017, 5:18:00 AM3/28/17
to snakeya...@googlegroups.com
Dear Niels,
every Node contains a Mark. The Mark has the line numbers.

Cheers,
Andrey

--
You received this message because you are subscribed to the Google Groups "SnakeYAML" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snakeyaml-core+unsubscribe@googlegroups.com.
To post to this group, send email to snakeyaml-core@googlegroups.com.
Visit this group at https://groups.google.com/group/snakeyaml-core.
For more options, visit https://groups.google.com/d/optout.



--
Andrey Somov

Niels Basjes

unread,
Mar 28, 2017, 7:41:56 AM3/28/17
to SnakeYAML
Hi Andrey,

Thanks!
I never noticed the 'Node' class before.

As a first test I changed my parsing from the original (which is what I found in your documentation)
    Object loadedYaml = yaml.load(yamlStream);
to this (which I constructed by reading your source)
    Node node = yaml.compose(new InputStreamReader(yamlStream));

The datastructure that comes out seems good to me.
Big question: Is this the correct way of doing this?

What is the recommended (easiest) way of walking around this tree?

Thanks.

Niels

Op dinsdag 28 maart 2017 11:18:00 UTC+2 schreef Andrey Somov:
Dear Niels,
every Node contains a Mark. The Mark has the line numbers.

Cheers,
Andrey
On Mon, Mar 27, 2017 at 9:20 PM, Niels Basjes <ni...@basj.es> wrote:
Hi,

In my application ( https://github.com/nielsbasjes/yauaa ) I read multiple Yaml files.
The settings found in those files are evaluated at startup and in some cases an error occurs in one of those settings.
Now from the yaml perspective these files are correct, yet from the perspective of my application they are not. 

What I would like is to show along with the filename also the line number where the error occurred. 
I have not found any reference to the line number in any of the datastructures that I get.
So perhaps you guys can advise me on how to handle this?

Thanks

Niels Basjes

--
You received this message because you are subscribed to the Google Groups "SnakeYAML" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snakeyaml-cor...@googlegroups.com.
To post to this group, send email to snakeya...@googlegroups.com.



--
Andrey Somov

Andrey Somov

unread,
Mar 28, 2017, 7:48:21 AM3/28/17
to snakeya...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to snakeyaml-core+unsubscribe@googlegroups.com.
To post to this group, send email to snakeyaml-core@googlegroups.com.



--
Andrey Somov

Andrey Somov

unread,
Mar 28, 2017, 9:35:14 AM3/28/17
to snakeya...@googlegroups.com
You can find the usage in the tests and in the production code.

Andrey

Andrey Somov

Niels Basjes

unread,
Mar 28, 2017, 9:59:03 AM3/28/17
to SnakeYAML
This is what I needed.
Thank you!

Op dinsdag 28 maart 2017 15:35:14 UTC+2 schreef Andrey Somov:
Andrey Somov
Reply all
Reply to author
Forward
0 new messages