/// <summary>
        /// Handles validation error tracing.
        /// </summary>
        /// <param name="request">The request details.</param>
        /// <param name="errors">The error details.</param>
        public void HandleValidationErrors(
            HotChocolateRequest request,
            IReadOnlyList <IError> errors)
        {
            if (errors == null)
            {
                throw new ArgumentNullException(nameof(errors));
            }

            if (errors.Count > 0)
            {
                var formattedErrors =
                    errors.Select(e =>
                                  new HotChocolateError
                {
                    Message   = e.Message,
                    Code      = e.Code,
                    Path      = e.Path?.ToList(),
                    Exception = e.Exception
                }).ToList();

                HotChocolateError firstError = formattedErrors[0];

                var message = firstError.Exception == null
                    ? firstError.Message
                    : firstError.Exception.Message;

                Log.OnValidationError(message, request, formattedErrors);
            }
        }
Пример #2
0
        /// <summary>
        /// Handles resolver error tracing.
        /// </summary>
        /// <param name="request">The request details.</param>
        /// <param name="errors">The error details.</param>
        public void HandlesResolverErrors(
            HotChocolateRequest request,
            IReadOnlyCollection <IError> errors)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (errors == null)
            {
                throw new ArgumentNullException(nameof(errors));
            }

            if (errors.Count > 0)
            {
                List <HotChocolateError> formattedErrors =
                    errors.Select(e =>
                                  new HotChocolateError
                {
                    Message   = e.Message,
                    Code      = e.Code,
                    Path      = e.Path,
                    Exception = e.Exception
                }).ToList();

                HotChocolateError firstError = formattedErrors[0];

                string message = firstError.Exception == null
                    ? firstError.Message
                    : firstError.Exception.Message;

                Log.OnResolverError(message, request, formattedErrors);
            }
        }