コード例 #1
0
        public static void AddGraphQLExceptions(this ExecutionErrors errors, Exception exception)
        {
            switch (exception)
            {
            case InvalidArgumentException invalidArgumentEx:
                errors.Add(new ExecutionError(invalidArgumentEx.Body));
                break;

            case NotFoundException notFoundEx:
                errors.Add(new ExecutionError(notFoundEx.Body));
                break;

            case BaseException baseEx:
                errors.AddRange(((List <ValidationFailure>)baseEx.Body).Select(validationFailure => new ExecutionError(validationFailure.ErrorMessage)));
                break;

            default:
                errors.Add(new ExecutionError(exception.Message));
                break;
            }
        }