private void SetMessageFormatter(Func <Exception, HttpContext, HandlerContext, Task> formatter)
        {
            if (formatter == null)
            {
                throw new NullReferenceException(nameof(formatter));
            }

            ExceptionConfig exceptionConfig = _configurations[_currentFluentlyConfiguredType];

            exceptionConfig.Formatter = formatter;
        }
        public IHandledFormatters ReturnStatusCode(int statusCode)
        {
            var exceptionConfig = new ExceptionConfig
            {
                StatusCode = statusCode
            };

            _configurations.Add(_currentFluentlyConfiguredType, exceptionConfig);

            return(this);
        }
        public IHasMessageFormatter ReturnStatusCode(HttpStatusCode statusCode)
        {
            var c = new ExceptionConfig
            {
                StatusCode = statusCode
            };

            _configurations.AddOrUpdate(_type, c, (type, config) => c);

            return(this);
        }
        IHandledFormatters ToStatusCode(Func <Exception, int> statusCodeResolver)
        {
            var exceptionConfig = new ExceptionConfig
            {
                StatusCodeResolver = statusCodeResolver
            };

            _configurations.Add(_currentFluentlyConfiguredType, exceptionConfig);

            return(this);
        }
Example #5
0
        private IHandledFormatters <TException> ToStatusCodeImpl(Func <TException, int> statusCodeResolver)
        {
            int WrappedResolver(Exception x) => statusCodeResolver((TException)x);

            var exceptionConfig = new ExceptionConfig
            {
                StatusCodeResolver = WrappedResolver
            };

            _configurations.Add(typeof(TException), exceptionConfig);

            return(this);
        }