Esempio n. 1
0
        public void UnchangedParametersInError(JsonErrorCode errorCode, JsonErrorLevel errorLevel, int start, int length, string[] parameters)
        {
            JsonErrorInfoParameter[] errorInfoParameters = parameters?.Select(x => new JsonErrorInfoParameter <string>(x))?.ToArrayEx();

            var errorInfo = new JsonErrorInfo(errorCode, errorLevel, start, length, errorInfoParameters);

            Assert.Equal(errorCode, errorInfo.ErrorCode);
            Assert.Equal(errorLevel, errorInfo.ErrorLevel);
            Assert.Equal(start, errorInfo.Start);
            Assert.Equal(length, errorInfo.Length);

            AssertErrorInfoParameters(errorInfo, errorInfoParameters);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of <see cref="JsonErrorInfo"/>.
        /// </summary>
        /// <param name="errorCode">
        /// The error code.
        /// </param>
        /// <param name="errorLevel">
        /// The severity level of the error.
        /// </param>
        /// <param name="start">
        /// The start position of the text span where the error occurred.
        /// </param>
        /// <param name="length">
        /// The length of the text span where the error occurred.
        /// </param>
        /// <param name="parameters">
        /// Parameters of the error.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Either <paramref name="start"/> or <paramref name="length"/>, or both are negative.
        /// </exception>
        public JsonErrorInfo(JsonErrorCode errorCode, JsonErrorLevel errorLevel, int start, int length, params JsonErrorInfoParameter[] parameters)
        {
            if (start < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(start));
            }
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            ErrorCode  = errorCode;
            ErrorLevel = errorLevel;
            Start      = start;
            Length     = length;
            Parameters = parameters != null
                ? ReadOnlyList <JsonErrorInfoParameter> .Create(parameters)
                : ReadOnlyList <JsonErrorInfoParameter> .Empty;
        }
Esempio n. 3
0
 public PTypeError(int start, int length, JsonErrorLevel errorLevel)
     : base(JsonErrorCode.Custom, errorLevel, start, length)
 {
 }