DRAFT: Non-panicking C API#472
Conversation
If by panicking you mean asserts in C API, then we simply have to improve the documentation. You must provide valid arguments. There is no point in returning an error in this case. |
|
Ok, now I understand that C API can only panic on breach of contract. It was difficult to see at first. Although I would prefer error code rather than panicking, it seems reasonable here because it makes the code much simpler. Thank you for taking a look at the PR, I'm closing it. |
|
I think it is a very useful pull request. The library reacts too brutally to various mistakes. |
|
The library itself is very forgiving. C API is not. Can you provide some concrete examples when the C API behaved in an unexpected way? |
|
Unfortunately there are no easy way to determine contract violations in any user input, e.g. server-side SVG file(in particular, there are no way it to do it in C API, but It's possible that I don't know about the proper way, sorry), so it would be very convenient to provide some flat C validation APIs maybe partially like this PR that I found, thanks in advance for your attention |
Hi!
I'm using resvg and it's really impressing. Thank you for your hard work!
But I've faced an issue with c-api. The issue is that C API functions can panic internally due to variety of reasons and therefore terminate the whole application. And I can't see any good way to handle these panics in C code.
Have you considered the possibility of making another C API that reports about all errors by returning an error code rather than panicking? (maybe along with current C API)
Here is my vision of such C API. Could you tell me what do you think about that? Has it a chance to be added to resvg?