Open JAicewizard opened 3 years ago
This error is definitely a cairo-specific error; the piet text API does not explicitly disallow nul bytes in strings. The piet
crate provides a single Error::Platform
variant that holds all platform originating errors.
So two thoughts:
cairo-rs
would be my first thought.PlatformError
does not need to just be us boxing whatever error we get back from cairo; we could, in piet-cairo
, define our own error variant that provides more information in some cases; then when we got an error back from cairo-rs
we might inspect it and then determine how best to convert it into a piet-cairo
error. This is a pragmatic solution; it gives us more control and flexibility, and also allows us to add more context; for instance if an error occurs when trying to create a text layout, we could include the problem string in the error, on our side.Thinking about this a bit more, I actually think I'm leaning towards the second option? I think the flexibility could be very helpful.
Currently creating something like a piet label containing a null byte as character will crash the program with a vague error and backtrace.
This could be improved by providing a proper error. Ideally cairo-rs should handle this, and I might end up filling an issue on them as well tomorrow.