Skip to content

refactor: propagate FFI load errors using Result instead of panicking #33

Description

@rvoidex7

Description

The constructor NativeEngine::new currently panics using .expect(...) if libloading fails to load the dynamic library (libCrawlCipher.Core.so/CrawlCipher.Core.dll) or any of the exported functions. It also uses .unwrap() when creating CString instances, which can panic if inputs contain interior NUL bytes.

If a developer runs the game without having the core binary in place, the application crashes immediately with a raw Rust panic message, which is bad for UX.

Proposed Changes

  1. Refactor NativeEngine::new to return anyhow::Result<Self> instead of panicking.
  2. Replace .expect and .unwrap calls inside the constructor with proper error propagation (?).
  3. Catch the error in main.rs, disable raw mode/leave alternate screen, and print a clean diagnostic error message prompting the user to check their shared library paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions