linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

[piet-cairo] Provide propper error for strings containing null before passing to cairo #447

Open JAicewizard opened 3 years ago

JAicewizard commented 3 years ago

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.

cmyr commented 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:

Thinking about this a bit more, I actually think I'm leaning towards the second option? I think the flexibility could be very helpful.