示例#1
0
            private static Exception ConvertToException(int statusCode, string statusDescription)
            {
                Exception messagingException;

                if (!Enum.IsDefined(typeof(HttpStatusCode), statusCode))
                {
                    messagingException = new MessagingException(SRAmqp.AmqpPutTokenFailed(statusCode, statusDescription));
                }
                else
                {
                    HttpStatusCode httpStatusCode = (HttpStatusCode)statusCode;
                    if (httpStatusCode == HttpStatusCode.BadRequest)
                    {
                        messagingException = new ArgumentException(SRAmqp.AmqpPutTokenFailed(statusCode, statusDescription));
                    }
                    else if (httpStatusCode == HttpStatusCode.NotFound)
                    {
                        messagingException = new MessagingEntityNotFoundException(SRAmqp.AmqpPutTokenFailed(statusCode, statusDescription));
                    }
                    else
                    {
                        messagingException = new MessagingException(SRAmqp.AmqpPutTokenFailed(statusCode, statusDescription));
                    }
                }
                return(messagingException);
            }