Skip to content

AdsOverMQTT hijacks previous exception types when failed to connect #248

@legrab

Description

@legrab

The recently added AdsOverMQTT connection type now throws a barebone Exception with some message as AmsServer 'AdsOverMqtt' is not set!

While I understand that there is a way to configure the connection to be ADS-only, I still believe that the exception here should be some sort of AmsServerException or other identifiable implementation and not a random Exception to handle it distinctly.

Note that previously, with no connection setup, it was either LoopbackNotRegisteredException or AdsServerException that was thrown here and it was possible to rely on that to handle the cases. Now one would need to rely on the message of the exception which is undesired.

Please consider using some existing exception type such as AdsServerException or add a new type instead (as suggested above: AmsServerException sounds legit to me) instead of falling back to generic Exception type.

System.Exception: AmsServer 'AdsOverMqtt' is not set!
   at TwinCAT.Ads.AmsServerComposition.GetServerFactory(ChannelProtocol channelProtocol)
   at TwinCAT.Ads.Server.AmsServer.createDIChannel(ChannelProtocol requestedProtocol, ChannelPortType requestedPortType)
   at TwinCAT.Ads.Server.AmsServer.createServerImplementation(ChannelProtocol requestedProtocol, ChannelPortType requestedPortType)
   at TwinCAT.Ads.Server.AmsServer.ConnectServer()
   at TwinCAT.Ads.Server.AdsServer.ConnectServer()
   at TwinCAT.Ads.AdsClient.Connect(AmsAddress address)
   at TwinCAT.Ads.AdsConnection.OnConnect()
   at TwinCAT.Ads.AdsConnection.Connect()
   at TwinCAT.Ads.AdsSessionBase.OnConnect(Boolean reconnect)
   at TwinCAT.Session.Connect()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions