-
Notifications
You must be signed in to change notification settings - Fork 200
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
One way that error messages could be more helpful #488
Comments
Thanks for sharing this. Unfortunately, I don't think there's a lot we can do here. Namely, this:
... is, unfortunately, out of our limits now, at least until we'd get our own YAML parser. Right now, we get just a ready-made tree, and there's no way we can get anything like that (i.e. with line numbers) — best we can do (and that's actually what we strive to do) is getting a YAML path like Also, This idea, on the other hand, might be doable:
I mean, if we just analyze whatever is going on right after the position in line where we stopped, and if first 2 symbols of that is So, to summarize, I guess the best we can do right now in theory is:
|
That would be a perfectly fine approach! I’m more used to seeing line/column type coordinates because most parsers make them the easiest to obtain, but a path-based error like that works almost as well. |
Do you know if anyone has built an Emacs extension that can interpret your path-based error messages so that the “jump to next error” functionality works, at least approximately? If not, I might investigate that… or, maybe not, since there generally seems to be only one error output before |
Should be fixed in current compiler. Test that proves it: expr_wrong_and.ksy. Error message would look similar to
I totally feel like we can do better with "expected ..." section of the message — but I don't quite understand exactly what is the better alternative. |
Unlikely, I'd love to do such extension too ;) |
That improved message helps! And it does look like it will be much harder to do something about the “expected…” section. It seems to at least be trying, but making a concise, human-readable format of the structure it seems to be working with is likely very challenging. |
Closing the issue for now. |
Opening this by request of @GreyCat. Last night I wasted a lot of time because in an earlier version of this line: https://github.com/Deep-Symmetry/beat-link/blob/5da596c526768a3f6df40d044754845f6397dc67/kaitai/pdb.ksy#L211 I had forgotten that the
ksc
expression language usesand
for conjoining boolean expressions, rather than&&
like most C-derived languages I generally use, so I had&&
instead of theand
there. Unfortunately, the error message I received was:That gave me no context whatsoever, not even the line number. It would have been far more helpful to say something like:
That would have at least sent me to the manual to look for the right thing. Since this is probably a common mistake, you could even be extra nice and say something like:
Something similar could be offered for
||
andor
.Even looking at the exception, now that I know that trick, did not help:
In the end, I spent a long time trying to separate the expression into simpler sub-expressions using additional parse instances to try to figure out what was going on, and eventually slapped my forehead and vented in the Gitter chat. Hopefully we can spare future adopters such fun. 😄
The text was updated successfully, but these errors were encountered: