prql icon indicating copy to clipboard operation
prql copied to clipboard

Offer the less-verbose error message in prql-js

Open max-sixty opened this issue 4 years ago • 7 comments

This is best described by @jiripospisil in https://github.com/prql/prql-code/pull/3

I think this is mostly a bindings question; how much of our Error type do we expose?

@charlie-sanders you've done much of the work there; if this might be something you might be interested in doing!

max-sixty avatar Sep 22 '22 21:09 max-sixty

Well we're coming back around to something @aljazerzen said that eventually we might want to expose the full error object instead of just a message, which I think was the way it was originally. We could go back to not throwing any errors and just return a CompileResult ala:


#[wasm_bindgen]
#[derive(Default)]
pub struct CompileResult {
    sql: Option<String>,
    error: Option<CompileError>,
}

Or we can just throw a textual error message instead of the highlighting, what do you think ?

qorrect avatar Oct 04 '22 12:10 qorrect

Wait sorry, the compile() method already returns the CompileResult, yeah let me take out the formatting for the to_sql exception message :+1:

qorrect avatar Oct 04 '22 13:10 qorrect

Yes, there is, but it only exposes message, which is the pretty-formatted output with source code.

I've just changed how error.rs works and also exposed line, which can be just the error line, without the annotated source code.

Can you take a look and check if it works? I haven't tested much, so things like Playground may be broken...

aljazerzen avatar Oct 04 '22 14:10 aljazerzen

Here: #1005

aljazerzen avatar Oct 04 '22 14:10 aljazerzen

Shall we close this? (Or do we need an addition to prql-js?)

CC @jiripospisil (no action needed unless you want to add this to prql-code, no obligation, 🙏 )

max-sixty avatar Oct 10 '22 17:10 max-sixty

@max-sixty Looks like everything necessary is in place. Have a look at https://github.com/prql/prql-code/pull/9.

jiripospisil avatar Oct 10 '22 19:10 jiripospisil

Wonderful, I'll close this

max-sixty avatar Oct 10 '22 20:10 max-sixty