You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently a lot of errors are handled in a manner similar to:
let dev = device.open_device(&hidapi).or(Err(Error::Transport(TransportError::ConnectionFailed)))?;
These errors are tricky to track down. Now that we're using the tracing crate fully, it would be best to rewrite these using let-else syntax, ie.:
letOk(dev) = device.open_device(&hidapi)else{error!(?hidapi,"Failed to open device");returnErr(Error::Transport(TransportError::ConnectionFailed));}
If the error is relevant to the message, first consider if the method being called should be instrumented to automatically log errors in their context:
use tracing::instrument;#[instrument(skipall, err)]pubfn open_device(&self,dev:&HidDevice){
...
If this is not possible, we can instead use match statements at the point of invocation:
let dev = match device.open_device(&hidapi){Ok(dev) => dev,Err(err) => {error!({ %err, ?hidapi },"Failed to open device");returnErr(Error::Transport(TransportError::ConnectionFailed));}};
The text was updated successfully, but these errors were encountered:
Currently a lot of errors are handled in a manner similar to:
These errors are tricky to track down. Now that we're using the
tracing
crate fully, it would be best to rewrite these usinglet-else
syntax, ie.:If the error is relevant to the message, first consider if the method being called should be instrumented to automatically log errors in their context:
If this is not possible, we can instead use match statements at the point of invocation:
The text was updated successfully, but these errors were encountered: