Skip to content

Commit d667cf2

Browse files
Merge pull request #67 from virizar/add_exception_log_unwinding_mqtt_relay
Added exception unwinding and logging on MqttRelay module when connecting to external broker
2 parents 5868596 + e2a518d commit d667cf2

File tree

1 file changed

+12
-2
lines changed
  • agent/Modules/MTConnect.NET-AgentModule-MqttRelay

1 file changed

+12
-2
lines changed

agent/Modules/MTConnect.NET-AgentModule-MqttRelay/Module.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,19 @@ private async Task Worker()
214214
await Task.Delay(100);
215215
}
216216
}
217-
catch (Exception ex)
217+
catch (Exception exception)
218218
{
219-
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error : {ex.Message}");
219+
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error : {exception.Message}");
220+
221+
var innerException = exception.InnerException;
222+
223+
while (innerException != null)
224+
{
225+
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error (InnerException) : {innerException.Message}");
226+
innerException = innerException.InnerException;
227+
}
228+
229+
Log(MTConnectLogLevel.Warning, $"MQTT Relay Connection Error (BaseException) : {exception.GetBaseException().ToString()}");
220230
}
221231
finally
222232
{

0 commit comments

Comments
 (0)