Пример #1
0
 private static void OnFinally(AsyncResult asyncResult, Exception exception)
 {
     if (exception != null)
     {
         throw ExceptionHelper.ToCommunicationContract(exception);
     }
 }
Пример #2
0
        public static Exception ToRelayContract(Exception exception)
        {
            AmqpException amqpException = exception as AmqpException;

            if (amqpException != null && amqpException.Error != null)
            {
                if (amqpException.Error.Condition.Equals(ClientConstants.RelayNotFoundError))
                {
                    return(new RelayNotFoundException(exception.Message, exception));
                }
                if (amqpException.Error.Condition.Equals(ClientConstants.AuthorizationFailedError))
                {
                    return(new AuthorizationFailedException(exception.Message, exception));
                }
            }
            return(ExceptionHelper.ToCommunicationContract(exception));
        }
Пример #3
0
            public void EndSend(IAsyncResult result)
            {
                SendingAmqpLink sendingAmqpLink;
                Outcome         outcome = this.Link.EndSendMessage(result);

                if (outcome.DescriptorCode != Accepted.Code)
                {
                    if (this.sharedAmqpLink != null)
                    {
                        this.sharedAmqpLink.Invalidate(out sendingAmqpLink);
                    }
                    Rejected rejected = outcome as Rejected;
                    if (rejected == null)
                    {
                        base.Fault();
                        throw Fx.Exception.AsWarning(new CommunicationObjectFaultedException(outcome.ToString()), null);
                    }
                    throw ExceptionHelper.ToCommunicationContract(rejected.Error, null);
                }
            }
Пример #4
0
        public static Exception ToCommunicationContract(Exception exception)
        {
            Exception     communicationContract = null;
            AmqpException amqpException         = exception as AmqpException;
            AmqpException amqpException1        = amqpException;

            if (amqpException != null)
            {
                communicationContract = ExceptionHelper.ToCommunicationContract(amqpException1.Error, amqpException1);
            }
            else if (exception is CommunicationException || exception is TimeoutException)
            {
                communicationContract = exception;
            }
            else
            {
                SocketException socketException  = exception as SocketException;
                SocketException socketException1 = socketException;
                if (socketException != null)
                {
                    if (socketException1.SocketErrorCode == SocketError.ConnectionRefused || socketException1.SocketErrorCode == SocketError.HostDown || socketException1.SocketErrorCode == SocketError.HostNotFound || socketException1.SocketErrorCode == SocketError.HostUnreachable)
                    {
                        communicationContract = new EndpointNotFoundException(socketException1.Message, socketException1);
                    }
                    else if (socketException1.SocketErrorCode == SocketError.TimedOut)
                    {
                        communicationContract = new TimeoutException(socketException1.Message, socketException1);
                    }
                }
            }
            if (communicationContract == null)
            {
                communicationContract = new CommunicationException(exception.Message, exception);
            }
            return(communicationContract);
        }