YOUSEFUL / DELPHI / COMPONENTS

EAtlasMqttError

Base class of every Atlas MQTT exception; raised for invalid arguments, settings and packets.

Class Unit Atlas.MqttCodec · Inherits Exception · Product Atlas MQTT

Description

Raised directly for mistakes the caller can fix, for example:

Descendants: EAtlasMqttProtocolError for malformed input, and EAtlasMqttTransportError for socket failures. Catch EAtlasMqttError to catch them all. Declared in Atlas.MqttCodec. Connection problems inside the client are not raised; they arrive through OnDisconnected and OnError.

This type has no members of its own beyond those listed in its description.

Examples

Publish without raising

Returns False instead of raising when the client refuses the message.

pascal
uses
  System.SysUtils, Atlas.MqttCodec, Atlas.MqttClient;

function TryPublish(Client: TAtlasMqttClient; const Topic, Text: string): Boolean;
begin
  try
    Client.Publish(Topic, Text, qosAtLeastOnce);
    Result := True;
  except
    on EAtlasMqttError do  // an invalid topic, or MaxInFlight messages already waiting
      Result := False;
  end;
end;

EAtlasMqttProtocolError · EAtlasMqttTransportError

Also in Atlas MQTT

TAtlasMqttClient · TAtlasMqttBroker