libprocessing ffi error handling by tychedelia · Pull Request #1293 · processing/processing4
I'm approving, but also curious about what things will look like, say, if they write an erroneous compute shader.
i think we'll def run into situations like this. what i'd propose is that we write a validate_shader ffi function that can eagerly check and return structured output. but also, there's nothing preventing us from returning a custom ffi error type for a given operation where it would be helpful, for example:
struct ValidationResult { error_code: u8, data: *const c_void, }
in rust applications, you typically will bubble up Result using ? to a top level handler that will either log or panic. and so the pattern in this pr basically just ensure that we can reliably return results from our internal library code.
on the java side, we're using unchecked exceptions. right now it's just a general "something went wrong" exception class, but we could totally add an error code in addition to message and sub-type more on the java side if we do want to throw something like ValidationException.