-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix panic on mismatching request/response function codes #254
Conversation
The seconds commit introduces another error variant that replaces |
I'm sorry, where exactly is the fix? |
} | ||
|
||
// Match function codes of request and response. | ||
let rsp_function_code = match &result { |
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.
The fix (RTU).
Ok(response) => response.function_code(), | ||
Err(ExceptionResponse { function, .. }) => *function, | ||
}; | ||
if req_function_code != rsp_function_code { |
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.
The fix (TCP).
I am still unsure if it would be more suitable to replace the outer |
The alternative approach of replacing the outer The different sources of errors are now separated more consistently, i.e. client/server communication vs. server-side processing. |
In general I'd look on the layers.
So my error design would be enum MyAppError {
Modbus(ModbusError),
// other app specific
}
enum ModbusError {
Transport(TransportError).
// other modbus specific
}
enum TransportError {
// ...
} So the top level error in this library would be a very specific error where |
😂 it looks like you had the same idea 😄 💯 |
Keeping the |
Fixes #252.