Copilot commented on code in PR #302:
URL: https://github.com/apache/fluss-rust/pull/302#discussion_r2796329652
##########
bindings/cpp/src/lib.rs:
##########
@@ -451,16 +451,25 @@ fn err_result(code: i32, msg: String) -> ffi::FfiResult {
}
}
+/// Convert a core Error to FfiResult, extracting the API error code when
available.
+fn err_from_core_error(e: &fcore::error::Error) -> ffi::FfiResult {
+ if let fcore::error::Error::FlussAPIError { api_error } = e {
+ err_result(api_error.code, api_error.message.clone())
+ } else {
+ err_result(0, e.to_string())
Review Comment:
In `err_from_core_error`, the non-API error branch returns `error_code = 0`,
but in the C++ `Result` type `Ok()` is defined as `error_code == 0`. This will
cause generic/core errors to be treated as success by C++ callers. Use a
non-zero generic error code for the fallback branch (keeping `api_error.code`
for `FlussAPIError`) so failures are never encoded as `0`.
```suggestion
// Use a non-zero generic error code so C++ callers do not treat
this as success.
err_result(-1, e.to_string())
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]