Skip to content

Commit

Permalink
MAIN: Change to separate error variants
Browse files Browse the repository at this point in the history
  • Loading branch information
naterichman committed Jul 4, 2024
1 parent 7ba76b1 commit f330540
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ul/src/association/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ use super::{
uid::trim_uid,
};

#[derive(Debug)]
pub enum ConnectOp {
Connect,
SetReadTimeout,
SetWriteTimeout
}

#[derive(Debug, Snafu)]
#[non_exhaustive]
pub enum Error {
Expand All @@ -43,7 +36,18 @@ pub enum Error {

/// could not connect to server
Connect {
op: ConnectOp,
source: std::io::Error,
backtrace: Backtrace,
},

/// Could not set tcp read timeout
SetReadTimeout{
source: std::io::Error,
backtrace: Backtrace,
},

/// Could not set tcp write timeout
SetWriteTimeout{
source: std::io::Error,
backtrace: Backtrace,
},
Expand Down Expand Up @@ -543,11 +547,11 @@ impl<'a> ClientAssociationOptions<'a> {
});

let mut socket = std::net::TcpStream::connect(ae_address)
.context(ConnectSnafu{op: ConnectOp::Connect})?;
.context(ConnectSnafu)?;
socket.set_read_timeout(read_timeout)
.context(ConnectSnafu{op: ConnectOp::SetReadTimeout})?;
.context(SetReadTimeoutSnafu)?;
socket.set_write_timeout(write_timeout)
.context(ConnectSnafu{op: ConnectOp::SetWriteTimeout})?;
.context(SetWriteTimeoutSnafu)?;
let mut buffer: Vec<u8> = Vec::with_capacity(max_pdu_length as usize);
// send request

Expand Down

0 comments on commit f330540

Please sign in to comment.