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 <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@Yury-Fridlyand Yury-Fridlyand force-pushed the csharp/dev_yuryf_fix_ut_on_mac branch from 1a6e9a7 to 70cc9d9 Compare March 7, 2024 00:08
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
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 <yury.fridlyand@improving.com>
@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