mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-25 15:42:57 +08:00
Refactor channel adapter.
This commit is contained in:
@@ -177,34 +177,17 @@ namespace MQTTnet.Adapter
|
|||||||
{
|
{
|
||||||
await action().ConfigureAwait(false);
|
await action().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
throw;
|
if (exception is TaskCanceledException ||
|
||||||
}
|
exception is OperationCanceledException ||
|
||||||
catch (OperationCanceledException)
|
exception is MqttCommunicationTimedOutException ||
|
||||||
{
|
exception is MqttCommunicationException)
|
||||||
throw;
|
|
||||||
}
|
|
||||||
catch (MqttCommunicationTimedOutException)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
catch (MqttCommunicationException)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
catch (COMException comException)
|
|
||||||
{
|
|
||||||
if ((uint)comException.HResult == ErrorOperationAborted)
|
|
||||||
{
|
{
|
||||||
throw new OperationCanceledException();
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new MqttCommunicationException(comException);
|
if (exception is IOException && exception.InnerException is SocketException socketException)
|
||||||
}
|
|
||||||
catch (IOException exception)
|
|
||||||
{
|
|
||||||
if (exception.InnerException is SocketException socketException)
|
|
||||||
{
|
{
|
||||||
if (socketException.SocketErrorCode == SocketError.ConnectionAborted)
|
if (socketException.SocketErrorCode == SocketError.ConnectionAborted)
|
||||||
{
|
{
|
||||||
@@ -212,10 +195,14 @@ namespace MQTTnet.Adapter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new MqttCommunicationException(exception);
|
if (exception is COMException comException)
|
||||||
}
|
{
|
||||||
catch (Exception exception)
|
if ((uint)comException.HResult == ErrorOperationAborted)
|
||||||
{
|
{
|
||||||
|
throw new OperationCanceledException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new MqttCommunicationException(exception);
|
throw new MqttCommunicationException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user