golemparts / rppal

A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
MIT License
1.21k stars 96 forks source link

Improve SPI error messages when using embedded_hal #140

Closed andber1 closed 5 months ago

andber1 commented 6 months ago

I removed the error conversions to an Error::Io. Is there a reason for this? This way you get more useful error messages. For example

called `Result::unwrap()` on an `Err` value: Io(Os { code: 90, kind: Uncategorized, message: "Message too long" })

instead of

called `Result::unwrap()` on an `Err` value: Io(Custom { kind: Other, error: "SimpleHalSpiDevice write transaction error" })
golemparts commented 6 months ago

While I'm not sure what the reasoning was for the conversions, I agree that the original error messages provide more useful information. I'll merge this in, unless someone has a specific reason to keep the error mapping.