public async void OnError()

in iothub/device/src/Transport/Mqtt/MqttTransportHandler.cs [700:752]


        public async void OnError(Exception exception)
        {
            if (Logging.IsEnabled)
                Logging.Enter(this, exception, nameof(OnError));

            try
            {
                TransportState previousState = MoveToStateIfPossible(TransportState.Error, TransportState.Closed);
                switch (previousState)
                {
                    case TransportState.Error:
                    case TransportState.Closed:
                        return;

                    case TransportState.NotInitialized:
                    case TransportState.Opening:
                        _fatalException = ExceptionDispatchInfo.Capture(exception);
                        _connectCompletion.TrySetException(exception);
                        _subscribeCompletionSource.TrySetException(exception);
                        break;

                    case TransportState.Open:
                    case TransportState.Subscribing:
                        _fatalException = ExceptionDispatchInfo.Capture(exception);
                        _subscribeCompletionSource.TrySetException(exception);
                        OnTransportDisconnected();
                        break;

                    case TransportState.Receiving:
                        _fatalException = ExceptionDispatchInfo.Capture(exception);
                        _disconnectAwaitersCancellationSource.Cancel();
                        OnTransportDisconnected();
                        break;

                    default:
                        string error = $"Unknown transport state: {previousState}";
                        Debug.Fail(error);
                        throw new InvalidOperationException(error);
                }

                await _closeRetryPolicy.RunWithRetryAsync(CleanUpImplAsync).ConfigureAwait(true);
            }
            catch (Exception ex) when (!ex.IsFatal())
            {
                if (Logging.IsEnabled)
                    Logging.Error(this, ex.ToString(), nameof(OnError));
            }
            finally
            {
                if (Logging.IsEnabled)
                    Logging.Exit(this, exception, nameof(OnError));
            }
        }