Files
MQTTnet/Source/MQTTnet/Client/Exceptions/MqttClientUnexpectedDisconnectReceivedException.cs
T
fazhoandchristian abbf14b1ec rethrow MqttClientUnexpectedDisconnectReceivedException when Publish … (#1974)
* rethrow MqttClientUnexpectedDisconnectReceivedException when Publish errors out because server disconnects the client and QoS is 0

* use a local var to cache _unexpectedDisconnectPacket

* Add inner exception to new exception

* Update release notes

* set the default inner exception as null

---------

Co-authored-by: christian <6939810+chkr1011@users.noreply.github.com>
2024-05-07 18:31:16 +02:00

36 lines
1.3 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using MQTTnet.Exceptions;
using MQTTnet.Packets;
using MQTTnet.Protocol;
namespace MQTTnet.Client
{
public sealed class MqttClientUnexpectedDisconnectReceivedException : MqttCommunicationException
{
public MqttClientUnexpectedDisconnectReceivedException(MqttDisconnectPacket disconnectPacket, Exception innerExcpetion = null) : base(
$"Unexpected DISCONNECT (Reason code={disconnectPacket.ReasonCode}) received.",
innerExcpetion)
{
ReasonCode = disconnectPacket.ReasonCode;
SessionExpiryInterval = disconnectPacket.SessionExpiryInterval;
ReasonString = disconnectPacket.ReasonString;
ServerReference = disconnectPacket.ServerReference;
UserProperties = disconnectPacket.UserProperties;
}
public MqttDisconnectReasonCode? ReasonCode { get; }
public string ReasonString { get; }
public string ServerReference { get; }
public uint? SessionExpiryInterval { get; }
public List<MqttUserProperty> UserProperties { get; }
}
}