YOUSEFUL / DELPHI / COMPONENTS
EAtlasMqttError
Base class of every Atlas MQTT exception; raised for invalid arguments, settings and packets.
Description
Raised directly for mistakes the caller can fix, for example:
- an invalid topic or filter;
Hostmissing, or an emptyClientIdwithoutCleanSession;KeepAliveorMaxInFlightout of range;- quality 0 published while not connected;
- the in-flight limit reached;
- a packet
TAtlasMqttCodec.Encodecannot encode.
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.
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;Related
EAtlasMqttProtocolError · EAtlasMqttTransportError