◐ Shell
reader mode source ↗
Skip to content

libprocessing ffi error handling#1293

Merged
catilac merged 2 commits into
processing:the-wgpu-momentfrom
tychedelia:1271-error-handling
Oct 17, 2025
Merged

libprocessing ffi error handling#1293
catilac merged 2 commits into
processing:the-wgpu-momentfrom
tychedelia:1271-error-handling

Conversation

@tychedelia

Copy link
Copy Markdown
Member

Sets up basic bevy App initialization and cross-FFI error handling.

Our strategy here is the following: Java should do any validation necessary before calling into the FFI layer. Errors are assumed to be unrecoverable and evidence of us doing something wrong. So we don't return error codes or anything but just check the error status as a string so we can at least throw a helpful exception for bug reports.

@tychedelia tychedelia requested a review from catilac October 16, 2025 20:59

@catilac catilac left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

Great! I like the error approach too. And if we ever for whatever reason needed to share more details then we can just serialize more information.

I'm approving, but also curious about what things will look like, say, if they write an erroneous compute shader.

@tychedelia

Copy link
Copy Markdown
Member Author

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.

@catilac catilac merged commit 33b8b52 into processing:the-wgpu-moment Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants