Skip to content

FFI methods panic on error instead of returning Result #3

Description

@AlexAxthelm

Background

The UniFFI/WASM FFI boundary in shared/src/ffi.rs currently uses
panic! to handle deserialization and serialization errors. Panicking
across an FFI boundary causes the host process (Swift/JS) to hard-crash
with no opportunity for error recovery.

What to change

Refactor the FFI methods to return Result<Vec<u8>, SomeError> instead
of panicking. UniFFI has native support for Result-returning functions,
so this should be straightforward to wire up on both the Rust and Swift
sides.

Scope

  • Define an appropriate error type (or reuse one from crux_core)
  • Update FFI method signatures in shared/src/ffi.rs
  • Update the Swift core.swift glue to handle the returned Result
  • Add tests covering the error path

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions