Skip to content

Commit

Permalink
Simplify naming of ProtocolError variants (#255)
Browse files Browse the repository at this point in the history
Easier to distinguish if they don't start with the same prefix.
  • Loading branch information
uklotzde committed Mar 27, 2024
1 parent c259882 commit b9b8065
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum ProtocolError {
///
/// The result received from the server is included for further analysis and handling.
#[error("mismatching headers: {message} {result:?}")]
MismatchingHeaders {
HeaderMismatch {
message: String,
result: Result<Response, ExceptionResponse>,
},
Expand All @@ -37,7 +37,7 @@ pub enum ProtocolError {
///
/// The result received from the server is included for further analysis and handling.
#[error("mismatching function codes: {request} {result:?}")]
MismatchingFunctionCodes {
FunctionCodeMismatch {
request: FunctionCode,
result: Result<Response, ExceptionResponse>,
},
Expand Down
4 changes: 2 additions & 2 deletions src/service/rtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where

// Match headers of request and response.
if let Err(message) = verify_response_header(&req_hdr, &res_adu.hdr) {
return Err(ProtocolError::MismatchingHeaders { message, result }.into());
return Err(ProtocolError::HeaderMismatch { message, result }.into());
}

// Match function codes of request and response.
Expand All @@ -75,7 +75,7 @@ where
Err(ExceptionResponse { function, .. }) => *function,
};
if req_function_code != rsp_function_code {
return Err(ProtocolError::MismatchingFunctionCodes {
return Err(ProtocolError::FunctionCodeMismatch {
request: req_function_code,
result,
}
Expand Down
4 changes: 2 additions & 2 deletions src/service/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where

// Match headers of request and response.
if let Err(message) = verify_response_header(&req_hdr, &res_adu.hdr) {
return Err(ProtocolError::MismatchingHeaders { message, result }.into());
return Err(ProtocolError::HeaderMismatch { message, result }.into());
}

// Match function codes of request and response.
Expand All @@ -98,7 +98,7 @@ where
Err(ExceptionResponse { function, .. }) => *function,
};
if req_function_code != rsp_function_code {
return Err(ProtocolError::MismatchingFunctionCodes {
return Err(ProtocolError::FunctionCodeMismatch {
request: req_function_code,
result,
}
Expand Down

0 comments on commit b9b8065

Please sign in to comment.