Skip to content

Commit

Permalink
Merge pull request #67 from virizar/add_exception_log_unwinding_mqtt_…
Browse files Browse the repository at this point in the history
…relay

Added exception unwinding and logging on MqttRelay module when connecting to external broker
  • Loading branch information
PatrickRitchie authored Jun 26, 2024
2 parents 5868596 + e2a518d commit d667cf2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions agent/Modules/MTConnect.NET-AgentModule-MqttRelay/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,19 @@ private async Task Worker()
await Task.Delay(100);
}
}
catch (Exception ex)
catch (Exception exception)
{
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error : {ex.Message}");
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error : {exception.Message}");

var innerException = exception.InnerException;

while (innerException != null)
{
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error (InnerException) : {innerException.Message}");
innerException = innerException.InnerException;
}

Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error (BaseException) : {exception.GetBaseException().ToString()}");
}
finally
{
Expand Down

0 comments on commit d667cf2

Please sign in to comment.