You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
improving the quality of error messages upstream is a good approach. They're receptive to PRs, and so trying to just improve this in cairo-rs would be my first thought.
The 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.
The text was updated successfully, but these errors were encountered: