embedded-hal-mock
embedded-hal-mock copied to clipboard
Error message specificity for empty Mock
In a few places there are error messages like this one:
https://github.com/dbrgn/embedded-hal-mock/blob/3ac0ada5110218682e0dd1939f74cd008ee6d912/src/eh1/pin.rs#L135
This error message is triggered when Mock is empty. I don't think including the method name set_low
is useful. Especially because it is followed by
assert_eq!(
kind,
TransactionKind::Set(State::Low),
"expected pin::set_low"
);
https://github.com/dbrgn/embedded-hal-mock/blob/3ac0ada5110218682e0dd1939f74cd008ee6d912/src/eh1/pin.rs#L137C1-L141C11
A more generic message should enable more code sharing and more succinct implementation.
Hm, I disagree. If you get a generic error message, this means that a HAL call was issued without an expectation.
If you don't know which call triggered this, it is very hard to debug the issue.
I don't think including the method name set_low is useful. Especially because it is followed by (...)
It doesn't matter what it's followed by, because the expect
call will immediately panic.
The error message can retain the function name and be generic with a crate such as function_name
, though this does have limitations.