I2C Device Sim incorrect read/write length handling

I am developing a sensor driver for BH1750 (light sensor) in Lua. Since adding it requires expanding Lua API with byte r/w I wanted to add the sensor to SITL but I stumbled.on msg.len.

How to handle unexpected read or write length on a simulated I2C device. I have seen two approaches.

  • Sending HAL panic.
  • Returning -1

Which one should I use? (Sensor is not critical)
Are there any other ways?