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

improve ReQL error messages #13

Open
tve opened this issue May 20, 2016 · 3 comments
Open

improve ReQL error messages #13

tve opened this issue May 20, 2016 · 3 comments

Comments

@tve
Copy link

tve commented May 20, 2016

I find the ReQL error messages in the UI very frustrating because they don't pinpoint the error location. For example, where does this error occur?

e: No attribute baz in object:
{
"links": {
"parent": "/api/resource/55"
}
} in:
r({"fields": {"color": "red", "size": 10, "shape": "round", "tags": ["awesome", "cool"], "margin": {"top": 0, "bot": 1}}, "databags": {"links": {"parent": "/api/resource/55"}}, "ix": ["color", "size", "tags", "margin", "baz"], "databag_ix": {"links": ["parent"], "baz": ["tada"]}}).do(function(var_63) { return var_63("ix").concatMap(function(var_64) { return r.branch(var_63("fields").hasFields(var_64), var_63("fields")(var_64).do(function(var_65) { return r.branch(var_65.typeOf().eq("ARRAY"), var_65.map(function(var_66) { return ["", var_64, var_66]; }), var_65.typeOf().eq("OBJECT"), var_65.keys().map(function(var_67) { return ["", var_67, var_65(var_67)]; }), [["", var_64, var_65]]); }), []); }).spliceAt(0, var_63("databag_ix").keys().concatMap(function(var_68) { return var_63("databag_ix")(var_68).default([]).concatMap(function(var_69) { return r.branch(var_63("databags")(var_68).default([]).hasFields(var_69), var_63("databags")(var_68)(var_69).do(function(var_70) { return r.branch(var_70.typeOf().eq("ARRAY"), var_70.map(function(var_71) { return [var_68, var_69, var_71]; }), var_70.typeOf().eq("OBJECT"), var_70.keys().map(function(var_72) { return [var_68, var_72, var_70(var_72)]; }), [[var_68, var_69, var_70]]); }), []); }); })); })
^^^^^^^^^^^^^^^^^^^^^^^^^^

I assume the line of ^ is intended to point to the error, but I can't for the life of me figure it out...
(Apologies if there is already an issue open for this, I couldn't find it).

@danielmewes
Copy link
Member

Indeed the ^^^^^^^^^^^^^^^^^^^^^^^^^^ should underline the failing part of the query. The way we print it obviously breaks down once the queries get longer than a single line.

It would be nice if we could change the formatting for backtraces in the Data Explorer so that it highlights the failing part in bold red or something like that, rather than trying to underline it with ^^^.

(additionally there are a few errors that don't generate correct backtraces so the ^ will end up underlining the whole query. This is a separate issue, and doesn't seem to be the case here)

@tve As a work-around, you might have more luck by copying the error output from the Data Explorer into an editor that doesn't break lines. Then the ^^^ should align with the part of the query that failed.

@mlucy
Copy link
Member

mlucy commented May 20, 2016

@danielmewes -- we could also move to multi-line pretty-printing in the JS driver. The Ruby driver prints queries like this:

r([{"foo" => "bar"}]).map {|var_25|
  r.branch(var_25["foo"].eq("bar"), r(100).div(0), 0)
                                    ^^^^^^^^^^^^^
}.map {|var_26| var_26.mul(var_26)}

which is both much easier to read, and makes it clearer where the error occured.

@danielmewes
Copy link
Member

Oh indeed. I like that solution because it will also work outside the Data Explorer (though you can probably construct queries for which the lines would still be too long).

@gabor-boros gabor-boros transferred this issue from rethinkdb/rethinkdb May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants