-
Notifications
You must be signed in to change notification settings - Fork 0
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
Handle error on command for FFI client + C# example #122
Conversation
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>
1a6e9a7
to
70cc9d9
Compare
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
csharp/lib/src/lib.rs
Outdated
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/src/lib.rs
Outdated
@@ -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())); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 93186f3
There was a problem hiding this 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>
This should go together with #114 to
glide-ffi
Note: no error handling on connection [yet]