/// <summary>
        /// Reads an inner error payload.
        /// </summary>
        /// <param name="recursionDepth">The number of times this method has been called recursively.</param>
        /// <returns>An <see cref="ODataInnerError"/> representing the read inner error.</returns>
        /// <remarks>
        /// Pre-Condition:  any                         - will throw if not StartObject
        /// Post-Condition: JsonNodeType.Property       - The next property in the error value
        ///                 JsonNodeType.EndObject      - The end of the error value
        /// </remarks>
        private ODataInnerError ReadInnerError(int recursionDepth)
        {
            Debug.Assert(this.JsonReader.DisableInStreamErrorDetection, "JsonReader.DisableInStreamErrorDetection");
            this.JsonReader.AssertNotBuffering();

            ValidationUtils.IncreaseAndValidateRecursionDepth(ref recursionDepth, this.MessageReaderSettings.MessageQuotas.MaxNestingDepth);

            this.JsonReader.ReadStartObject();

            ODataInnerError innerError = new ODataInnerError();

            ODataJsonReaderUtils.ErrorPropertyBitMask propertiesFoundBitField = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.JsonReader.NodeType == JsonNodeType.Property)
            {
                string propertyName = this.JsonReader.ReadPropertyName();
                switch (propertyName)
                {
                case JsonConstants.ODataErrorInnerErrorMessageName:
                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue,
                        JsonConstants.ODataErrorInnerErrorMessageName);
                    innerError.Message = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorInnerErrorMessageName);
                    break;

                case JsonConstants.ODataErrorInnerErrorTypeNameName:
                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.ErrorPropertyBitMask.TypeName,
                        JsonConstants.ODataErrorInnerErrorTypeNameName);
                    innerError.TypeName = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorInnerErrorTypeNameName);
                    break;

                case JsonConstants.ODataErrorInnerErrorStackTraceName:
                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.ErrorPropertyBitMask.StackTrace,
                        JsonConstants.ODataErrorInnerErrorStackTraceName);
                    innerError.StackTrace = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorInnerErrorStackTraceName);
                    break;

                case JsonConstants.ODataErrorInnerErrorInnerErrorName:
                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(
                        ref propertiesFoundBitField,
                        ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError,
                        JsonConstants.ODataErrorInnerErrorInnerErrorName);
                    innerError.InnerError = this.ReadInnerError(recursionDepth);
                    break;

                default:
                    // skip any unsupported properties in the inner error
                    this.JsonReader.SkipValue();
                    break;
                }
            }

            this.JsonReader.ReadEndObject();
            this.JsonReader.AssertNotBuffering();
            return(innerError);
        }
        private ODataInnerError ReadInnerError(int recursionDepth)
        {
            ValidationUtils.IncreaseAndValidateRecursionDepth(ref recursionDepth, base.MessageReaderSettings.MessageQuotas.MaxNestingDepth);
            base.JsonReader.ReadStartObject();
            ODataInnerError error = new ODataInnerError();

            ODataJsonReaderUtils.ErrorPropertyBitMask none = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (base.JsonReader.NodeType == JsonNodeType.Property)
            {
                string str2 = base.JsonReader.ReadPropertyName();
                if (str2 == null)
                {
                    goto Label_010E;
                }
                if (!(str2 == "message"))
                {
                    if (str2 == "type")
                    {
                        goto Label_00A2;
                    }
                    if (str2 == "stacktrace")
                    {
                        goto Label_00C8;
                    }
                    if (str2 == "internalexception")
                    {
                        goto Label_00F1;
                    }
                    goto Label_010E;
                }
                ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue, "message");
                error.Message = base.JsonReader.ReadStringValue("message");
                continue;
Label_00A2:
                ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.TypeName, "type");
                error.TypeName = base.JsonReader.ReadStringValue("type");
                continue;
Label_00C8:
                ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.StackTrace, "stacktrace");
                error.StackTrace = base.JsonReader.ReadStringValue("stacktrace");
                continue;
Label_00F1:
                ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError, "internalexception");
                error.InnerError = this.ReadInnerError(recursionDepth);
                continue;
Label_010E:
                base.JsonReader.SkipValue();
            }
            base.JsonReader.ReadEndObject();
            return(error);
        }
Exemple #3
0
        private bool TryReadMessagePropertyValue(ODataError error)
        {
            this.ReadInternal();
            if (this.currentBufferedNode.NodeType != JsonNodeType.StartObject)
            {
                return(false);
            }
            this.ReadInternal();
            ODataJsonReaderUtils.ErrorPropertyBitMask none = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.currentBufferedNode.NodeType == JsonNodeType.Property)
            {
                string str2;
                string str3;
                string str4 = (string)this.currentBufferedNode.Value;
                if (str4 == null)
                {
                    goto Label_009D;
                }
                if (!(str4 == "lang"))
                {
                    if (str4 == "value")
                    {
                        goto Label_007B;
                    }
                    goto Label_009D;
                }
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageLanguage) && this.TryReadErrorStringPropertyValue(out str2))
                {
                    error.MessageLanguage = str2;
                    goto Label_009F;
                }
                return(false);

Label_007B:
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue) && this.TryReadErrorStringPropertyValue(out str3))
                {
                    error.Message = str3;
                    goto Label_009F;
                }
                return(false);

Label_009D:
                return(false);

Label_009F:
                this.ReadInternal();
            }
            return(true);
        }
        /// <summary>
        /// Checks whether the specified property has already been found before.
        /// </summary>
        /// <param name="propertiesFoundBitField">
        /// The bit field which stores which properties of an error or inner error were found so far.
        /// </param>
        /// <param name="propertyFoundBitMask">The bit mask for the property to check.</param>
        /// <returns>true if the property has not been read before; otherwise false.</returns>
        internal static bool ErrorPropertyNotFound(
            ref ODataJsonReaderUtils.ErrorPropertyBitMask propertiesFoundBitField,
            ODataJsonReaderUtils.ErrorPropertyBitMask propertyFoundBitMask)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(((int)propertyFoundBitMask & (((int)propertyFoundBitMask) - 1)) == 0, "propertyFoundBitMask is not a power of 2.");

            if ((propertiesFoundBitField & propertyFoundBitMask) == propertyFoundBitMask)
            {
                return(false);
            }

            propertiesFoundBitField |= propertyFoundBitMask;
            return(true);
        }
        /// <summary>
        /// Read a top-level error.
        /// </summary>
        /// <returns>An <see cref="ODataError"/> representing the read error.</returns>
        internal ODataError ReadTopLevelError()
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(this.JsonReader.NodeType == JsonNodeType.None, "Pre-Condition: expected JsonNodeType.None, the reader must not have been used yet.");
            Debug.Assert(!this.JsonReader.DisableInStreamErrorDetection, "!JsonReader.DisableInStreamErrorDetection");
            this.JsonReader.AssertNotBuffering();

            // prevent the buffering JSON reader from detecting in-stream errors - we read the error ourselves
            // to throw proper exceptions
            this.JsonReader.DisableInStreamErrorDetection = true;

            ODataError error = new ODataError();

            try
            {
                // Read the start of the payload (no "d" wrapper for top-level errors)
                this.ReadPayloadStart(/*isReadingNestedPayload*/ false, /*expectResponseWrapper*/ false);

                // Read the start of the error object
                this.JsonReader.ReadStartObject();

                ODataJsonReaderUtils.ErrorPropertyBitMask propertiesFoundBitField = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
                while (this.JsonReader.NodeType == JsonNodeType.Property)
                {
                    string propertyName = this.JsonReader.ReadPropertyName();
                    if (string.CompareOrdinal(JsonConstants.ODataErrorName, propertyName) != 0)
                    {
                        // we only allow a single 'error' property for a top-level error object
                        throw new ODataException(Strings.ODataJsonErrorDeserializer_TopLevelErrorWithInvalidProperty(propertyName));
                    }

                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.ErrorPropertyBitMask.Error, JsonConstants.ODataErrorName);

                    this.JsonReader.ReadStartObject();

                    while (this.JsonReader.NodeType == JsonNodeType.Property)
                    {
                        propertyName = this.JsonReader.ReadPropertyName();
                        switch (propertyName)
                        {
                        case JsonConstants.ODataErrorCodeName:
                            ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.ErrorPropertyBitMask.Code, JsonConstants.ODataErrorCodeName);
                            error.ErrorCode = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorCodeName);
                            break;

                        case JsonConstants.ODataErrorMessageName:
                            ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.ErrorPropertyBitMask.Message, JsonConstants.ODataErrorMessageName);
                            this.JsonReader.ReadStartObject();

                            while (this.JsonReader.NodeType == JsonNodeType.Property)
                            {
                                propertyName = this.JsonReader.ReadPropertyName();
                                switch (propertyName)
                                {
                                case JsonConstants.ODataErrorMessageLanguageName:
                                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageLanguage, JsonConstants.ODataErrorMessageLanguageName);
                                    error.MessageLanguage = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorMessageLanguageName);
                                    break;

                                case JsonConstants.ODataErrorMessageValueName:
                                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue, JsonConstants.ODataErrorMessageValueName);
                                    error.Message = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorMessageValueName);
                                    break;

                                default:
                                    // we only allow a 'lang' and 'value' properties in the value of the 'message' property
                                    throw new ODataException(Strings.ODataJsonErrorDeserializer_TopLevelErrorMessageValueWithInvalidProperty(propertyName));
                                }
                            }

                            this.JsonReader.ReadEndObject();
                            break;

                        case JsonConstants.ODataErrorInnerErrorName:
                            ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref propertiesFoundBitField, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError, JsonConstants.ODataErrorInnerErrorName);
                            error.InnerError = this.ReadInnerError(0 /* recursionDepth */);
                            break;

                        default:
                            // we only allow a 'code', 'message' and 'innererror' properties in the value of the 'error' property
                            throw new ODataException(Strings.ODataJsonErrorDeserializer_TopLevelErrorValueWithInvalidProperty(propertyName));
                        }
                    }

                    this.JsonReader.ReadEndObject();
                }

                // Read the end of the error object
                this.JsonReader.ReadEndObject();

                // Read the end of the response (no "d" wrapper for top-level errors)
                this.ReadPayloadEnd(/*isReadingNestedPayload*/ false, /*expectResponseWrapper*/ false);
            }
            finally
            {
                this.JsonReader.DisableInStreamErrorDetection = false;
            }

            Debug.Assert(this.JsonReader.NodeType == JsonNodeType.EndOfInput, "Post-Condition: JsonNodeType.EndOfInput");
            this.JsonReader.AssertNotBuffering();

            return(error);
        }
Exemple #6
0
        /// <summary>
        /// Try to read an inner error property value.
        /// </summary>
        /// <param name="innerError">An <see cref="ODataInnerError"/> instance that was read from the reader or null if none could be read.</param>
        /// <param name="recursionDepth">The number of times this method has been called recursively.</param>
        /// <returns>true if an <see cref="ODataInnerError"/> instance that was read; otherwise false.</returns>
        private bool TryReadInnerErrorPropertyValue(out ODataInnerError innerError, int recursionDepth)
        {
            Debug.Assert(this.currentBufferedNode.NodeType == JsonNodeType.Property, "this.currentBufferedNode.NodeType == JsonNodeType.Property");
            Debug.Assert(this.parsingInStreamError, "this.parsingInStreamError");
            this.AssertBuffering();

            ValidationUtils.IncreaseAndValidateRecursionDepth(ref recursionDepth, this.maxInnerErrorDepth);

            // move the reader onto the property value
            this.ReadInternal();

            // we expect a start-object node here
            if (this.currentBufferedNode.NodeType != JsonNodeType.StartObject)
            {
                innerError = null;
                return(false);
            }

            // read the start-object node
            this.ReadInternal();

            innerError = new ODataInnerError();

            // we expect one of the supported properties for the value (or end-object)
            ODataJsonReaderUtils.ErrorPropertyBitMask propertiesFoundBitmask = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.currentBufferedNode.NodeType == JsonNodeType.Property)
            {
                // NOTE the Json reader already ensures that the value of a property node is a string
                string propertyName = (string)this.currentBufferedNode.Value;

                switch (propertyName)
                {
                case JsonConstants.ODataErrorInnerErrorMessageName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue))
                    {
                        return(false);
                    }

                    string message;
                    if (this.TryReadErrorStringPropertyValue(out message))
                    {
                        innerError.Message = message;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                case JsonConstants.ODataErrorInnerErrorTypeNameName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.TypeName))
                    {
                        return(false);
                    }

                    string typeName;
                    if (this.TryReadErrorStringPropertyValue(out typeName))
                    {
                        innerError.TypeName = typeName;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                case JsonConstants.ODataErrorInnerErrorStackTraceName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.StackTrace))
                    {
                        return(false);
                    }

                    string stackTrace;
                    if (this.TryReadErrorStringPropertyValue(out stackTrace))
                    {
                        innerError.StackTrace = stackTrace;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                case JsonConstants.ODataErrorInnerErrorInnerErrorName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError))
                    {
                        return(false);
                    }

                    ODataInnerError nestedInnerError;
                    if (this.TryReadInnerErrorPropertyValue(out nestedInnerError, recursionDepth))
                    {
                        innerError.InnerError = nestedInnerError;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                default:
                    // if we find a non-supported property in an inner error, we skip it
                    this.SkipValueInternal();
                    break;
                }

                this.ReadInternal();
            }

            Debug.Assert(this.currentBufferedNode.NodeType == JsonNodeType.EndObject, "this.currentBufferedNode.NodeType == JsonNodeType.EndObject");

            return(true);
        }
Exemple #7
0
        /// <summary>
        /// Try to read the message property value of an error value.
        /// </summary>
        /// <param name="error">An <see cref="ODataError"/> instance to set the read message property values on.</param>
        /// <returns>true if the message property values could be read; otherwise false.</returns>
        private bool TryReadMessagePropertyValue(ODataError error)
        {
            Debug.Assert(error != null, "error != null");
            Debug.Assert(this.currentBufferedNode.NodeType == JsonNodeType.Property, "this.currentBufferedNode.NodeType == JsonNodeType.Property");
            Debug.Assert(this.parsingInStreamError, "this.parsingInStreamError");
            this.AssertBuffering();

            // move the reader onto the property value
            this.ReadInternal();

            // we expect a start-object node here
            if (this.currentBufferedNode.NodeType != JsonNodeType.StartObject)
            {
                return(false);
            }

            // read the start-object node
            this.ReadInternal();

            // we expect one of the supported properties for the value (or end-object)
            ODataJsonReaderUtils.ErrorPropertyBitMask propertiesFoundBitmask = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.currentBufferedNode.NodeType == JsonNodeType.Property)
            {
                // NOTE the Json reader already ensures that the value of a property node is a string
                string propertyName = (string)this.currentBufferedNode.Value;

                switch (propertyName)
                {
                case JsonConstants.ODataErrorMessageLanguageName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageLanguage))
                    {
                        return(false);
                    }

                    string lang;
                    if (this.TryReadErrorStringPropertyValue(out lang))
                    {
                        error.MessageLanguage = lang;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                case JsonConstants.ODataErrorMessageValueName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue))
                    {
                        return(false);
                    }

                    string message;
                    if (this.TryReadErrorStringPropertyValue(out message))
                    {
                        error.Message = message;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                default:
                    // if we find a non-supported property we don't treat this as an error
                    return(false);
                }

                this.ReadInternal();
            }

            Debug.Assert(this.currentBufferedNode.NodeType == JsonNodeType.EndObject, "this.currentBufferedNode.NodeType == JsonNodeType.EndObject");

            return(true);
        }
Exemple #8
0
        /// <summary>
        /// Try to read an error structure from the stream. Return null if no error structure can be read.
        /// </summary>
        /// <param name="error">An <see cref="ODataError"/> instance that was read from the reader or null if none could be read.</param>
        /// <returns>true if an <see cref="ODataError"/> instance that was read; otherwise false.</returns>
        private bool TryReadErrorPropertyValue(out ODataError error)
        {
            Debug.Assert(this.parsingInStreamError, "this.parsingInStreamError");
            this.AssertBuffering();

            error = null;

            // we expect a start-object node here
            if (this.currentBufferedNode.NodeType != JsonNodeType.StartObject)
            {
                return(false);
            }

            // read the start-object node
            this.ReadInternal();

            error = new ODataError();

            // we expect one of the supported properties for the value (or end-object)
            ODataJsonReaderUtils.ErrorPropertyBitMask propertiesFoundBitmask = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.currentBufferedNode.NodeType == JsonNodeType.Property)
            {
                // NOTE the Json reader already ensures that the value of a property node is a string
                string propertyName = (string)this.currentBufferedNode.Value;
                switch (propertyName)
                {
                case JsonConstants.ODataErrorCodeName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.Code))
                    {
                        return(false);
                    }

                    string errorCode;
                    if (this.TryReadErrorStringPropertyValue(out errorCode))
                    {
                        error.ErrorCode = errorCode;
                    }
                    else
                    {
                        return(false);
                    }

                    break;

                case JsonConstants.ODataErrorMessageName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.Message))
                    {
                        return(false);
                    }

                    if (!this.TryReadMessagePropertyValue(error))
                    {
                        return(false);
                    }

                    break;

                case JsonConstants.ODataErrorInnerErrorName:
                    if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref propertiesFoundBitmask, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError))
                    {
                        return(false);
                    }

                    ODataInnerError innerError;
                    if (!this.TryReadInnerErrorPropertyValue(out innerError, 0 /*recursionDepth */))
                    {
                        return(false);
                    }

                    error.InnerError = innerError;
                    break;

                default:
                    // if we find a non-supported property we don't treat this as an error
                    return(false);
                }

                this.ReadInternal();
            }

            // read the end object
            Debug.Assert(this.currentBufferedNode.NodeType == JsonNodeType.EndObject, "this.currentBufferedNode.NodeType == JsonNodeType.EndObject");
            this.ReadInternal();

            // if we don't find any properties it is not a valid error object
            return(propertiesFoundBitmask != ODataJsonReaderUtils.ErrorPropertyBitMask.None);
        }
        internal ODataError ReadTopLevelError()
        {
            base.JsonReader.DisableInStreamErrorDetection = true;
            ODataError error = new ODataError();

            try
            {
                base.ReadPayloadStart(false, false);
                base.JsonReader.ReadStartObject();
                ODataJsonReaderUtils.ErrorPropertyBitMask none = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
                while (base.JsonReader.NodeType == JsonNodeType.Property)
                {
                    string strB = base.JsonReader.ReadPropertyName();
                    if (string.CompareOrdinal("error", strB) != 0)
                    {
                        throw new ODataException(Strings.ODataJsonErrorDeserializer_TopLevelErrorWithInvalidProperty(strB));
                    }
                    ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.Error, "error");
                    base.JsonReader.ReadStartObject();
                    while (base.JsonReader.NodeType == JsonNodeType.Property)
                    {
                        strB = base.JsonReader.ReadPropertyName();
                        string str2 = strB;
                        if (str2 == null)
                        {
                            goto Label_01B8;
                        }
                        if (!(str2 == "code"))
                        {
                            if (str2 == "message")
                            {
                                goto Label_00D9;
                            }
                            if (str2 == "innererror")
                            {
                                goto Label_019B;
                            }
                            goto Label_01B8;
                        }
                        ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.Code, "code");
                        error.ErrorCode = base.JsonReader.ReadStringValue("code");
                        continue;
Label_00D9:
                        ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.Message, "message");
                        base.JsonReader.ReadStartObject();
                        while (base.JsonReader.NodeType == JsonNodeType.Property)
                        {
                            strB = base.JsonReader.ReadPropertyName();
                            string str3 = strB;
                            if (str3 == null)
                            {
                                goto Label_0171;
                            }
                            if (!(str3 == "lang"))
                            {
                                if (str3 == "value")
                                {
                                    goto Label_014B;
                                }
                                goto Label_0171;
                            }
                            ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageLanguage, "lang");
                            error.MessageLanguage = base.JsonReader.ReadStringValue("lang");
                            continue;
Label_014B:
                            ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue, "value");
                            error.Message = base.JsonReader.ReadStringValue("value");
                            continue;
Label_0171:
                            throw new ODataException(Strings.ODataJsonErrorDeserializer_TopLevelErrorMessageValueWithInvalidProperty(strB));
                        }
                        base.JsonReader.ReadEndObject();
                        continue;
Label_019B:
                        ODataJsonReaderUtils.VerifyErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError, "innererror");
                        error.InnerError = this.ReadInnerError(0);
                        continue;
Label_01B8:
                        throw new ODataException(Strings.ODataJsonErrorDeserializer_TopLevelErrorValueWithInvalidProperty(strB));
                    }
                    base.JsonReader.ReadEndObject();
                }
                base.JsonReader.ReadEndObject();
                base.ReadPayloadEnd(false, false);
            }
            finally
            {
                base.JsonReader.DisableInStreamErrorDetection = false;
            }
            return(error);
        }
Exemple #10
0
        private bool TryReadInnerErrorPropertyValue(out ODataInnerError innerError, int recursionDepth)
        {
            ValidationUtils.IncreaseAndValidateRecursionDepth(ref recursionDepth, this.maxInnerErrorDepth);
            this.ReadInternal();
            if (this.currentBufferedNode.NodeType != JsonNodeType.StartObject)
            {
                innerError = null;
                return(false);
            }
            this.ReadInternal();
            innerError = new ODataInnerError();
            ODataJsonReaderUtils.ErrorPropertyBitMask none = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.currentBufferedNode.NodeType == JsonNodeType.Property)
            {
                string          str2;
                string          str3;
                string          str4;
                ODataInnerError error;
                string          str5 = (string)this.currentBufferedNode.Value;
                if (str5 == null)
                {
                    goto Label_0125;
                }
                if (!(str5 == "message"))
                {
                    if (str5 == "type")
                    {
                        goto Label_00B6;
                    }
                    if (str5 == "stacktrace")
                    {
                        goto Label_00D9;
                    }
                    if (str5 == "internalexception")
                    {
                        goto Label_0100;
                    }
                    goto Label_0125;
                }
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.MessageValue) && this.TryReadErrorStringPropertyValue(out str2))
                {
                    innerError.Message = str2;
                    goto Label_012B;
                }
                return(false);

Label_00B6:
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.TypeName) && this.TryReadErrorStringPropertyValue(out str3))
                {
                    innerError.TypeName = str3;
                    goto Label_012B;
                }
                return(false);

Label_00D9:
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.StackTrace) && this.TryReadErrorStringPropertyValue(out str4))
                {
                    innerError.StackTrace = str4;
                    goto Label_012B;
                }
                return(false);

Label_0100:
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError) && this.TryReadInnerErrorPropertyValue(out error, recursionDepth))
                {
                    innerError.InnerError = error;
                    goto Label_012B;
                }
                return(false);

Label_0125:
                this.SkipValueInternal();
Label_012B:
                this.ReadInternal();
            }
            return(true);
        }
Exemple #11
0
        private bool TryReadErrorPropertyValue(out ODataError error)
        {
            error = null;
            if (this.currentBufferedNode.NodeType != JsonNodeType.StartObject)
            {
                return(false);
            }
            this.ReadInternal();
            error = new ODataError();
            ODataJsonReaderUtils.ErrorPropertyBitMask none = ODataJsonReaderUtils.ErrorPropertyBitMask.None;
            while (this.currentBufferedNode.NodeType == JsonNodeType.Property)
            {
                string          str2;
                ODataInnerError error2;
                string          str3 = (string)this.currentBufferedNode.Value;
                if (str3 == null)
                {
                    goto Label_00CC;
                }
                if (!(str3 == "code"))
                {
                    if (str3 == "message")
                    {
                        goto Label_0090;
                    }
                    if (str3 == "innererror")
                    {
                        goto Label_00A8;
                    }
                    goto Label_00CC;
                }
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.Code) && this.TryReadErrorStringPropertyValue(out str2))
                {
                    error.ErrorCode = str2;
                    goto Label_00CE;
                }
                return(false);

Label_0090:
                if (ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.Message) && this.TryReadMessagePropertyValue(error))
                {
                    goto Label_00CE;
                }
                return(false);

Label_00A8:
                if (!ODataJsonReaderUtils.ErrorPropertyNotFound(ref none, ODataJsonReaderUtils.ErrorPropertyBitMask.InnerError))
                {
                    return(false);
                }
                if (!this.TryReadInnerErrorPropertyValue(out error2, 0))
                {
                    return(false);
                }
                error.InnerError = error2;
                goto Label_00CE;
Label_00CC:
                return(false);

Label_00CE:
                this.ReadInternal();
            }
            this.ReadInternal();
            return(none != ODataJsonReaderUtils.ErrorPropertyBitMask.None);
        }