Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle error on command for FFI client + C# example #122

Conversation

Yury-Fridlyand
Copy link

@Yury-Fridlyand Yury-Fridlyand commented Mar 1, 2024

This should go together with #114 to glide-ffi
Note: no error handling on connection [yet]

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Err(_) => (client.failure_callback)(callback_index), // TODO - report errors
Err(err) => {
logger_core::log_debug("command error", format!("callback {}, error {}, kind {:?}, code {:?}, category {:?}, detail {:?}", callback_index, err, err.kind(), err.code(), err.category(), err.detail()));
let c_err_str = CString::new(error_message(&err)).expect("CString::new failed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think we need expect here. We could probably use unwrap instead and it would be just as helpful wrt debug info. Applies throughout.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 93186f3

@@ -118,7 +119,11 @@ pub extern "C" fn set(
let client = Box::leak(Box::from_raw(ptr_address as *mut Client));
match result {
Ok(_) => (client.success_callback)(callback_index, std::ptr::null()), // TODO - should return "OK" string.
Err(_) => (client.failure_callback)(callback_index), // TODO - report errors
Err(err) => {
logger_core::log_debug("command error", format!("callback {}, error {}, kind {:?}, code {:?}, category {:?}, detail {:?}", callback_index, err, err.kind(), err.code(), err.category(), err.detail()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't err implement Debug or Display? I think we should be able to just print it without explicitly extracting the kind, code, category, and detail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 93186f3

csharp/lib/AsyncClient.cs Outdated Show resolved Hide resolved
Copy link

@jonathanl-bq jonathanl-bq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor comments.

Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand deleted the branch csharp/integ_yuryf_fix_ut_on_mac July 19, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants