Amqp.Connection.OnException C# (CSharp) Method

OnException() private method

private OnException ( Exception exception ) : void
exception System.Exception
return void
        void OnException(Exception exception)
        {
            Trace.WriteLine(TraceLevel.Error, "Exception occurred: {0}", exception.ToString());
            AmqpException amqpException = exception as AmqpException;
            Error error = amqpException != null ?
                amqpException.Error :
                new Error() { Condition = ErrorCode.InternalError, Description = exception.Message };

            if (this.state < State.ClosePipe)
            {
                try
                {
                    this.Close(0, error);
                }
                catch
                {
                    this.state = State.End;
                }
            }
            else
            {
                this.state = State.End;
            }

            if (this.state == State.End)
            {
                this.OnEnded(error);
            }
        }

Usage Example

Beispiel #1
0
 async Task StartAsync(Connection connection)
 {
     try
     {
         await this.PumpAsync(connection.MaxFrameSize, connection.OnHeader, connection.OnFrame).ConfigureAwait(false);
     }
     catch (AmqpException amqpException)
     {
         connection.OnException(amqpException);
     }
     catch (Exception exception)
     {
         connection.OnIoException(exception);
     }
 }