Skip to content

Commit 9b2b792

Browse files
committed
Wrap ffi calls with catch_unwind.
1 parent 5fdc335 commit 9b2b792

File tree

3 files changed

+237
-163
lines changed

3 files changed

+237
-163
lines changed

data-pipeline-ffi/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ crate-type = ["lib", "staticlib", "cdylib"]
1515
bench = false
1616

1717
[features]
18-
default = ["cbindgen"]
18+
default = ["cbindgen", "catch_panic"]
19+
catch_panic = []
1920
cbindgen = ["build_common/cbindgen", "ddcommon-ffi/cbindgen"]
2021

2122
[build-dependencies]

data-pipeline-ffi/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub enum ExporterErrorCode {
3232
NetworkUnknown,
3333
Serde,
3434
TimedOut,
35+
#[cfg(feature = "catch_panic")]
36+
Panic,
3537
}
3638

3739
impl Display for ExporterErrorCode {
@@ -57,6 +59,8 @@ impl Display for ExporterErrorCode {
5759
Self::NetworkUnknown => write!(f, "Unknown network error"),
5860
Self::Serde => write!(f, "Serialization/Deserialization error"),
5961
Self::TimedOut => write!(f, "Operation timed out"),
62+
#[cfg(feature = "catch_panic")]
63+
Self::Panic => write!(f, "Operation panicked"),
6064
}
6165
}
6266
}

0 commit comments

Comments
 (0)