コード例 #1
0
        public static IReadOnlyList <IClientError>?ParseErrors(JsonElement result)
        {
            if (result is { ValueKind : JsonValueKind.Array } errors)
            {
                var array = new IClientError[errors.GetArrayLength()];
                var i     = 0;

                foreach (JsonElement error in errors.EnumerateArray())
                {
                    try
                    {
                        array[i] = ParseError(error);
                    }
                    catch (Exception ex)
                    {
                        array[i] = new ClientError(
                            JsonErrorParser_ParseErrors_Error,
                            exception: ex);
                    }
                    i++;
                }

                return(array);
            }

            return(null);
        }
コード例 #2
0
        public GraphQLClientException(IClientError error)
            : base(error?.Message)
        {
            if (error is null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            Errors = new[] { error };
        }
コード例 #3
0
        /// <summary>
        /// Creates a new exception that is caused by the specified client <see cref="error"/>.
        /// </summary>
        /// <param name="error">
        /// The client error.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="error"/> is <c>null</c>.
        /// </exception>
        public GraphQLClientException(IClientError error)
        {
            if (error is null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            Message = error.Message;
            Errors  = new[] { error };
        }
コード例 #4
0
 public ResultMock(IClientError error)
 {
     Errors = new[] { error };
 }