pimoroni / bme680-python

Python library for the BME680 gas, temperature, humidity and pressure sensor.
https://shop.pimoroni.com/products/bme680
MIT License
260 stars 93 forks source link

Catch IOError, raise as RuntimeError in init() #35

Closed imgrant closed 3 years ago

imgrant commented 3 years ago

When checking the chip ID in init() (to confirm whether the device is a BME680 or not), errors of type IOError are not caught, unlike the pimoroni/bme280-python library, where a try/except block is used to catch an IOError and re-raise as RuntimeError instead.

This arises, for example, when trying to initialise the device when it doesn't exist at the address. It's not show-stopper, but I thought it might be preferable to be consistent across the two libraries, so this PR adopts the convention used in bme280-python and raises a RuntimeError in this situation.

Tangentially relevant to issues #19, #23, #10

Gadgetoid commented 3 years ago

Great idea. Thank you!