예제 #1
0
        public void OnResultExecuting(ResultExecutingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (!(context.Result is IClientErrorActionResult clientError))
            {
                return;
            }

            // We do not have an upper bound on the allowed status code. This allows this filter to be used
            // for 5xx and later status codes.
            if (clientError.StatusCode < 400)
            {
                return;
            }

            var result = _clientErrorFactory.GetClientError(context, clientError);

            if (result == null)
            {
                return;
            }

            _logger.TransformingClientError(context.Result.GetType(), result.GetType(), clientError.StatusCode);
            context.Result = result;
        }
예제 #2
0
        public void OnResultExecuting(ResultExecutingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (!(context.Result is IClientErrorActionResult clientError))
            {
                return;
            }

            var result = _clientErrorFactory.GetClientError(context, clientError);

            if (result == null)
            {
                return;
            }

            _logger.TransformingClientError(context.Result.GetType(), result?.GetType(), clientError.StatusCode);
            context.Result = result;
        }