/// <summary>
        /// Converts the <paramref name="httpError"/> to an <see cref="ODataError"/>.
        /// </summary>
        /// <param name="httpError">The <see cref="HttpError"/> instance to convert.</param>
        /// <returns>The converted <see cref="ODataError"/></returns>
        public static ODataError ToODataError(this HttpError httpError)
        {
            if (httpError == null)
            {
                throw Error.ArgumentNull("httpError");
            }

            return(new ODataError()
            {
                Message = httpError.GetPropertyValue <string>(HttpErrorKeys.MessageKey),
                MessageLanguage = httpError.GetPropertyValue <string>(HttpErrorKeys.MessageLanguageKey),
                ErrorCode = httpError.GetPropertyValue <string>(HttpErrorKeys.ErrorCodeKey),
                InnerError = httpError.ToODataInnerError()
            });
        }
        private static ODataInnerError ToODataInnerError(this HttpError httpError)
        {
            string innerErrorMessage = httpError.GetPropertyValue <string>(ExceptionMessageKey);

            if (innerErrorMessage == null)
            {
                return(null);
            }
            else
            {
                ODataInnerError innerError = new ODataInnerError();
                innerError.Message    = innerErrorMessage;
                innerError.TypeName   = httpError.GetPropertyValue <string>(ExceptionTypeKey);
                innerError.StackTrace = httpError.GetPropertyValue <string>(StackTraceKey);
                HttpError innerExceptionError = httpError.GetPropertyValue <HttpError>(InnerExceptionKey);
                if (innerExceptionError != null)
                {
                    innerError.InnerError = innerExceptionError.ToODataInnerError();
                }
                return(innerError);
            }
        }
        private static ODataInnerError ToODataInnerError(this HttpError httpError)
        {
            string innerErrorMessage = httpError.GetPropertyValue <string>(HttpErrorKeys.ExceptionMessageKey);

            if (innerErrorMessage == null)
            {
                string messageDetail = httpError.GetPropertyValue <string>(HttpErrorKeys.MessageDetailKey);
                if (messageDetail == null)
                {
                    HttpError modelStateError = httpError.GetPropertyValue <HttpError>(HttpErrorKeys.ModelStateKey);
                    return(modelStateError == null ? null : new ODataInnerError {
                        Message = ConvertModelStateErrors(modelStateError)
                    });
                }
                else
                {
                    return(new ODataInnerError()
                    {
                        Message = messageDetail
                    });
                }
            }
            else
            {
                ODataInnerError innerError = new ODataInnerError();
                innerError.Message    = innerErrorMessage;
                innerError.TypeName   = httpError.GetPropertyValue <string>(HttpErrorKeys.ExceptionTypeKey);
                innerError.StackTrace = httpError.GetPropertyValue <string>(HttpErrorKeys.StackTraceKey);
                HttpError innerExceptionError = httpError.GetPropertyValue <HttpError>(HttpErrorKeys.InnerExceptionKey);
                if (innerExceptionError != null)
                {
                    innerError.InnerError = innerExceptionError.ToODataInnerError();
                }
                return(innerError);
            }
        }