Skip to content

ModbusTcpClient .Initialize throws Exception -> hard to catch / determine what went wrong #139

@JaggerJo

Description

@JaggerJo

Hey @Apollo3zehn 👋

First, great library - thanks for maintaining.

We are having a small problem with Initialize on the ModbusTcpClient. We want to periodically retry to connect if connecting fails. We could do that by wrapping the call to initialise in a try catch, the issue is that we'd need to catch all exceptions.

if (remoteEndpoint is not null && !tcpClient.ConnectAsync(remoteEndpoint.Address, remoteEndpoint.Port).Wait(ConnectTimeout))
throw new Exception(ErrorMessage.ModbusClient_TcpConnectTimeout);

It would be nice to throw a special kind of exception here so that we can only catch e.g. FluentModbusException instead of Exception.

What do you think?

Are we completely missing something here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions