public string GetMessage()
        {
            var message = string.Empty;

            if (Success)
            {
                return(message);
            }
            if (Header.Status == ResponseStatus.VBucketBelongsToAnotherServer)
            {
                message = ResponseStatus.VBucketBelongsToAnotherServer.ToString();
            }
            else
            {
                if (ErrorCode != null)
                {
                    message = ErrorCode.ToString();
                }
                else if (Exception == null)
                {
                    try
                    {
                        if (Header.Status != ResponseStatus.Success)
                        {
                            if (Data == null || Data.Length == 0)
                            {
                                message = string.Empty;
                            }
                            else
                            {
                                var buffer = Data.ToArray();
                                if (buffer.Length > 0 && TotalLength == 24)
                                {
                                    message = Converter.ToString(buffer, 0, buffer.Length);
                                }
                                else
                                {
                                    message = Converter.ToString(buffer, 24, Math.Min(buffer.Length - 24, TotalLength - 24));
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        message = e.Message;
                    }
                }
                else
                {
                    message = Exception.Message;
                }
            }
            return(message);
        }
Exemple #2
0
        private string GetResponseBodyAsString()
        {
            var body = string.Empty;

            if (GetResponseStatus() != ResponseStatus.Success && Data != null && Data.Length > 0)
            {
                var buffer = Data.ToArray();
                if (buffer.Length > 0 && TotalLength == OperationHeader.Length)
                {
                    body = Converter.ToString(buffer, 0, buffer.Length);
                }
                else
                {
                    body = Converter.ToString(buffer, OperationHeader.Length, Math.Min(buffer.Length - OperationHeader.Length, TotalLength - OperationHeader.Length));
                }
            }

            return(body);
        }
        public virtual string GetMessage()
        {
            var message = string.Empty;

            if (Success)
            {
                return(message);
            }
            if (Header.Status == ResponseStatus.VBucketBelongsToAnotherServer)
            {
                message = ResponseStatus.VBucketBelongsToAnotherServer.ToString();
            }
            else
            {
                if (Exception == null)
                {
                    try
                    {
                        if (Header.Status != ResponseStatus.Success)
                        {
                            var buffer = Data.ToArray();
                            message = Converter.ToString(buffer, 24, TotalLength - 24);
                        }
                    }
                    catch (Exception e)
                    {
                        message = e.Message;
                    }
                }
                else
                {
                    message = Exception.Message;
                }
            }
            return(message);
        }