vega / vl-convert

Utilities for converting Vega-Lite specs from the command line and Python
BSD 3-Clause "New" or "Revised" License
96 stars 12 forks source link

Raise a Python error if a JS error was encountered #47

Open binste opened 1 year ago

binste commented 1 year ago

The JavaScript error reported in #46 does not raise a corresponding Python error. Instead, vl-convert still returns an svg string but the svg itself is wrong due to the error which happened on the JS level:

image

Would it be possible to raise all JS errors? Especially when generating a large number of charts, it would be important to know if everything worked as expected.

jonmmease commented 1 year ago

I'll take a closer look at what's going on. I believe some JS errors do result in Python errors (like when the input spec is invalid), but I think the issue in #46 is that the error occurs in a custom callback function that's registered with Vega, and Vega keeps on going when the callback raises an exception.

binste commented 1 year ago

Thank you, that's much appreciated! I'm not familiar enough with rust and JS to contribute to this issue or #46 but let me know if there is something on the Python level that can be done.

jonmmease commented 1 year ago

I played around with this a bit, but I can't figure out yet why exceptions raised in our text width calculation function don't propagate up to becoming exceptions in the SVG export function (but are instead printed as error).