Skip to content

Document how exceptions are handled #109

Description

@ShaddyDC

I'm evaluating different options to use C++ code from rust, and an important point for me is that error handling should be seamless. It would be convenient if what happens when an exception crosses the boundary was documented somewhere.
The only relevant information I found was #21.

If anybody else wonders as well, I've now tried it myself, and it results in this crash:

let result = unsafe {
    cpp!([] -> i32 as "std::int32_t" {
            throw std::runtime_error("oops");
            return 0;
        })
    };
fatal runtime error: Rust cannot catch foreign exceptions
Aborted (core dumped)

In hindsight, this is the obvious behaviour, but it's still useful to have it explicitly mentioned.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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