gron icon indicating copy to clipboard operation
gron copied to clipboard

add line number to error messages

Open hexpunk opened this issue 6 years ago • 1 comments

Very cool tool. I haven't done anything serious with it yet. I've only been playing around so far. But I did notice that error messages don't include the line number they occurred on. For large files, that could be a bit irksome.

gron

I tried a few things just to see what kind of errors I'd get. All of them made sense, but I wouldn't want to have to go hunting through a huge JSON file if I didn't have to. Line numbers in the errors would be appreciated.

--ungron

In most situations, the error message should give you enough context to figure out where it came from despite a lack of a line number. However, I did discover while I was fooling around that trying to "ungron" a line that looks like "test"; will throw ungron failed for ``: invalid statement. That doesn't give me anything go on to figure out where the problem is.

hexpunk avatar Apr 08 '18 05:04 hexpunk

Hi @JayAndCatchFire! Thanks for raising an issue!

As per issue #33, this might actually be very difficult to for the gron mode because of Go's JSON parser not exposing any information about line numbers - although things may be slightly easier in this case because it's only a requirement in the event of an error.

It should definitely be possible to improve things for the --ungron mode though. Leave it with me and I'll see what I can come up with.

Thanks again!

tomnomnom avatar Apr 09 '18 09:04 tomnomnom