Пример #1
0
        private void ProcessBindingFailure(HttpContext context, TBinder binder)
        {
            Debug.Assert(context != null);

            var errors = binder.BindingErrors;
            HttpQueryBinderException exception;

            var errorsCount = errors.Count();

            if (errorsCount > 1)
            {
                exception = new HttpQueryBinderException(
                    Strings.HttpHandlerBase_BindingFailure,
                    new AggregateException(errors));
            }
            else if (errorsCount == 1)
            {
                // FIXME: Handle null.
                exception = errors.First();
            }
            else
            {
                exception = new HttpQueryBinderException(Strings.HttpHandlerBase_UnknownBindingFailure);
            }

            OnBindingFailure(context, exception);
        }
Пример #2
0
        protected virtual void OnBindingFailure(HttpContext context, HttpQueryBinderException exception)
        {
            Require.NotNull(context, nameof(context));
            Require.NotNull(exception, nameof(exception));

            var response = context.Response;

            response.SetStatusCode(HttpStatusCode.BadRequest);
            response.Write(exception.Message);
        }
Пример #3
0
 protected void AddError(HttpQueryBinderException exception) => _errors.Add(exception);