One try catch instead of two for DcDcDeviceRecord Read()

This commit is contained in:
atef 2023-09-12 19:31:39 +02:00
parent b213d97537
commit c51250a380
2 changed files with 12 additions and 22 deletions

View File

@ -35,22 +35,12 @@ public class TruConvertDcDcDevices
public DcDcDevicesRecord Read() public DcDcDevicesRecord Read()
{ {
SystemControlRegisters? scStatus;
try try
{ {
scStatus = _SystemControl.Read(); var scStatus = _SystemControl.Read();
}
catch (Exception e)
{
Console.WriteLine(e);
return DcDcDevicesRecord.Null;
}
var n = scStatus.NumberOfConnectedSlaves; var n = scStatus.NumberOfConnectedSlaves;
try
{
var dcDcRecords = _DcDcs var dcDcRecords = _DcDcs
.Take(n) .Take(n)
.Select(dcdc => dcdc.Read()) .Select(dcdc => dcdc.Read())
@ -61,7 +51,7 @@ public class TruConvertDcDcDevices
catch catch
{ {
"Failed to read DCDC data".WriteLine(); "Failed to read DCDC data".WriteLine();
return new DcDcDevicesRecord(scStatus, Array.Empty<DcDcRecord>()); return new DcDcDevicesRecord(null, Array.Empty<DcDcRecord>());
} }
} }