Ejemplo n.º 1
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            var members = context.Members
                          .ToArray();

            foreach (var member in members)
            {
                var method = member as MethodBase;
                if (method == null ||
                    method.IsSpecialName ||
                    method is not MethodInfo ||
                    !method.IsPublic)
                {
                    continue;
                }

                method = FindInterfaceMethod(method);
                if (method != null)
                {
                    context.Members.Add(method);
                }
            }

            await next();
        }
Ejemplo n.º 2
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            if (context.TargetSite != null)
            {
                context.Members.Add(context.TargetSite);
            }

            await next();
        }
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            await next();

            if (context.Message == null &&
                context.Exception is TException typedException)
            {
                context.Message = _selector(typedException);
            }
        }
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            var exception = context.Exception;

            if (exception?.InnerException != null)
            {
                context.InnerExceptions.Add(exception.InnerException);
            }

            await next();
        }
Ejemplo n.º 5
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            if (context.Exception is AggregateException aggregateException)
            {
                var flattenExceptions = aggregateException.Flatten().InnerExceptions;
                foreach (var flattenException in flattenExceptions)
                {
                    context.InnerExceptions.Add(flattenException);
                }
            }

            await next();
        }
Ejemplo n.º 6
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            var members = context.Members
                          .ToArray();

            foreach (var member in members)
            {
                if (member is not Type &&
                    member.DeclaringType != null)
                {
                    context.Members.Add(member.DeclaringType);
                }
            }

            await next();
        }
Ejemplo n.º 7
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            await next();

            if (context.Code == null)
            {
                var errorCode = context.Members
                                .Select(member => _errorCodeProvider.GetOrDefaultAsync(member))
                                .FirstOrDefault();

                if (errorCode != null)
                {
                    context.Code = errorCode;
                }
            }
        }
Ejemplo n.º 8
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            var method = context.TargetSite;

            if (method?.Name == nameof(IAsyncStateMachine.MoveNext) &&
                method.DeclaringType?.IsAssignableTo(typeof(IAsyncStateMachine)) == true)
            {
                var asyncMethod = FindDeclaredMethod(method);
                if (asyncMethod != null)
                {
                    context.Members.Add(asyncMethod);
                    context.Members.Remove(method);
                }
            }

            await next();
        }
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            await next();

            if (context.Message == null)
            {
                var attribute = context.Members
                                .Select(x => x.GetCustomAttributes <TAttribute>())
                                .Where(x => x != null)
                                .SelectMany(x => x)
                                .FirstOrDefault();

                if (attribute != null)
                {
                    context.Message = _selector(attribute);
                }
            }
        }
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            await next();

            context.Message ??= FormattableStringFactory.Create(_errorMessage);
        }
Ejemplo n.º 11
0
        public async Task OnProcessingAsync(ErrorDetailContext context, Func <Task> next)
        {
            await next();

            context.Code ??= _errorCode;
        }