Handle ArgumentException in Bme680Sensor

This commit is contained in:
Denis-Cosmin Nutiu 2020-08-01 16:28:35 +03:00
parent 8f9962c3b1
commit 47d22cae41

View file

@ -101,9 +101,11 @@ namespace NucuCar.Sensors.Environment
} }
catch (System.IO.IOException e) catch (System.IO.IOException e)
{ {
Logger?.LogError($"{DateTimeOffset.Now}:BME680 Sensor initialization FAIL."); HandleInitializationException(e);
Logger?.LogTrace(e.Message); }
CurrentState = SensorStateEnum.Error; catch (ArgumentException e)
{
HandleInitializationException(e);
} }
} }
@ -169,5 +171,12 @@ namespace NucuCar.Sensors.Environment
} }
public Bme680Sensor Object { get; } public Bme680Sensor Object { get; }
private void HandleInitializationException(Exception e)
{
Logger?.LogError($"{DateTimeOffset.Now}:BME680 Sensor initialization FAIL.");
Logger?.LogDebug(e.Message);
CurrentState = SensorStateEnum.Error;
}
} }
} }