rethinkdb / rethinkdb

The open-source database for the realtime web.
https://rethinkdb.com
Other
26.76k stars 1.86k forks source link

Proposal: have r.error accept any argument type and be variadic #1712

Open AtnNn opened 10 years ago

AtnNn commented 10 years ago

This would help debugging large queries. I find myself inserting code like this when debugging:

... .do(lambda x: r.branch(x.typeOf() == "ARRAY"), r.error(r.expr(["should not be an array", x].coerce_to("string"), x)) ...

I propose that the error call be allowed to be written as:

r.error("should not be an array", x)
coffeemug commented 10 years ago

This sounds like a really good idea. It would help a lot with debugging.

Also, #329 is relevant (and perhaps should be discussed now that we have the query profiler).

jdoliner commented 10 years ago

Another option here might be just having a "log" function which lets you put any reql value directly in to the profiling results as a "log" event. This way you can do it multiple times and still get the real output of the query.

On Wednesday, November 27, 2013, coffeemug wrote:

This sounds like a really good idea. It would help a lot with debugging.

Also, #329 https://github.com/rethinkdb/rethinkdb/issues/329 is relevant (and perhaps should be discussed now that we have the query profiler).

— Reply to this email directly or view it on GitHubhttps://github.com/rethinkdb/rethinkdb/issues/1712#issuecomment-29370489 .

coffeemug commented 10 years ago

Another option here might be just having a "log" function which lets you put any reql value directly in to the profiling results as a "log" event.

That sounds awesome (that's what #329 refers to). I still think it would be good to make error more flexible, though. I can see myself using both primitives in different circumstances.