Skip to content

Commit

Permalink
Fix logger is null Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-dmxc committed Jan 27, 2024
1 parent 589b150 commit 0f61d42
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions RDMSharp/RDM/AbstractRDMDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private async Task processMessage(RDMMessage rdmMessage)
}
catch (Exception ex)
{
Logger.LogError(string.Empty, ex);
Logger?.LogError(string.Empty, ex);
}
if (value == null)
return;
Expand Down Expand Up @@ -167,9 +167,9 @@ private async Task processMessage(RDMMessage rdmMessage)
if (!(value is RDMSlotDescription description))
{
if (value != null)
Logger.LogError($"The response does not contain the expected data {typeof(RDMSlotDescription)}!{Environment.NewLine}{rdmMessage}");
Logger?.LogError($"The response does not contain the expected data {typeof(RDMSlotDescription)}!{Environment.NewLine}{rdmMessage}");
else
Logger.LogTrace($"No response received");
Logger?.LogTrace($"No response received");
return;
}
Slot slot;
Expand All @@ -188,7 +188,7 @@ private async Task processMessage(RDMMessage rdmMessage)
if (rdmMessage.NackReason.Contains(ERDM_NackReason.ACTION_NOT_SUPPORTED))
this.slots = null; //Set to null, to Deactivate this UpdateSlotInfo

Logger.LogError($"The response does not contain the expected data {typeof(RDMSlotInfo[])}!{Environment.NewLine}{rdmMessage}");
Logger?.LogError($"The response does not contain the expected data {typeof(RDMSlotInfo[])}!{Environment.NewLine}{rdmMessage}");
return;
}

Expand All @@ -209,7 +209,7 @@ private async Task processMessage(RDMMessage rdmMessage)
case DefaultSlotValueParameterWrapper _defaultSlotValueParameterWrapper:
if (!(value is RDMDefaultSlotValue[] defaultSlotValues))
{
Logger.LogError($"The response does not contain the expected data {typeof(RDMDefaultSlotValue[])}!{Environment.NewLine}{rdmMessage}");
Logger?.LogError($"The response does not contain the expected data {typeof(RDMDefaultSlotValue[])}!{Environment.NewLine}{rdmMessage}");
return;
}

Expand All @@ -229,9 +229,9 @@ private async Task processMessage(RDMMessage rdmMessage)
if (!(value is RDMSensorValue sensorValue))
{
if (value != null)
Logger.LogError($"The response does not contain the expected data {typeof(RDMSensorValue)}!{Environment.NewLine}{rdmMessage}");
Logger?.LogError($"The response does not contain the expected data {typeof(RDMSensorValue)}!{Environment.NewLine}{rdmMessage}");
else
Logger.LogError($"No response received");
Logger?.LogError($"No response received");
return;
}
sensorValues.AddOrUpdate(sensorValue.SensorId, sensorValue, (x, y) => sensorValue);
Expand Down Expand Up @@ -273,7 +273,7 @@ public async Task UpdateParameterValues()
}
catch (Exception e)
{
Logger.LogError($"Not able to get UpdateParameterValues for UID: {this.UID}", e);
Logger?.LogError($"Not able to get UpdateParameterValues for UID: {this.UID}", e);
}
}
public async Task UpdateParameterValue(ERDM_Parameter parameterId)
Expand Down Expand Up @@ -302,7 +302,7 @@ public async Task UpdateParameterValue(ERDM_Parameter parameterId)
pm = deviceModel.GetRDMParameterWrapperByID((ushort)parameterId);
if (pm == null)
{
Logger.LogDebug("Not Implemented Parameter");
Logger?.LogDebug("Not Implemented Parameter");
return;
}

Expand Down Expand Up @@ -363,7 +363,7 @@ public async Task UpdateParameterValue(ERDM_Parameter parameterId)
}
catch (Exception e)
{
Logger.LogError($"Not able to update ParameterValue of Parameter: {parameterId} for UID: {this.UID}", e);
Logger?.LogError($"Not able to update ParameterValue of Parameter: {parameterId} for UID: {this.UID}", e);
}
this.pendingParametersUpdateRequest.Remove(parameterId);
}
Expand Down Expand Up @@ -391,7 +391,7 @@ public async Task UpdateSensorValues()
}
catch (Exception e)
{
Logger.LogError($"Not able to update SensorValues for UID: {this.UID}", e);
Logger?.LogError($"Not able to update SensorValues for UID: {this.UID}", e);
}
}
public async Task UpdateSensorValue(byte sensorId)
Expand All @@ -413,7 +413,7 @@ public async Task UpdateSensorValue(byte sensorId)
}
catch (Exception e)
{
Logger.LogError($"Not able to update SensorValue of Sensor: {sensorId} for UID: {this.UID}", e);
Logger?.LogError($"Not able to update SensorValue of Sensor: {sensorId} for UID: {this.UID}", e);
}
this.pendingSensorValuesUpdateRequest.Remove(sensorId);
}
Expand All @@ -437,7 +437,7 @@ public async Task UpdateSlotInfo()
}
catch (Exception e)
{
Logger.LogError($"Not able to update SlotInfo for UID: {this.UID}", e);
Logger?.LogError($"Not able to update SlotInfo for UID: {this.UID}", e);
}
}
public async Task UpdateDefaultSlotValue()
Expand All @@ -460,7 +460,7 @@ public async Task UpdateDefaultSlotValue()
}
catch (Exception e)
{
Logger.LogError($"Not able to update DefaultSlotValue for UID: {this.UID}", e);
Logger?.LogError($"Not able to update DefaultSlotValue for UID: {this.UID}", e);
}
}
public async Task UpdateSlotDescriptions()
Expand All @@ -484,7 +484,7 @@ public async Task UpdateSlotDescriptions()
}
catch (Exception e)
{
Logger.LogError($"Not able to update SlotDescriptions for UID: {this.UID}", e);
Logger?.LogError($"Not able to update SlotDescriptions for UID: {this.UID}", e);
}
}
public async Task UpdateSlotDescription(ushort slotId)
Expand All @@ -507,7 +507,7 @@ public async Task UpdateSlotDescription(ushort slotId)
}
catch (Exception e)
{
Logger.LogError($"Not able to update SlotDescription of Slot: {slotId} for UID: {this.UID}", e);
Logger?.LogError($"Not able to update SlotDescription of Slot: {slotId} for UID: {this.UID}", e);
}
this.pendingSlotDescriptionsUpdateRequest.Remove(slotId);
}
Expand Down

0 comments on commit 0f61d42

Please sign in to comment.