Exemple #1
0
        public virtual void HandleCore(ExceptionHandlerContext context)
        {
            context.ThrowIfNull();

            var content = Constants.Messages.DefaultErrorMessage;

#if DEBUG
            content = context.Exception.Message;
#endif
            var request       = context.ExceptionContext.Request;
            var configuration = context.ExceptionContext.ControllerContext.Configuration;
            var negociator    = configuration.Services.GetContentNegotiator();
            var negotiation   = negociator.Negotiate(
                typeof(string), request, configuration.Formatters);

            context.Result = new ErrorResult
            {
                Request = request,
                Content = new ObjectContent <string>(
                    content,
                    negotiation.Formatter,
                    negotiation.MediaType)
            };
        }
Exemple #2
0
        public virtual bool ShouldHandle(ExceptionHandlerContext context)
        {
            context.ThrowIfNull();

            return(context.ExceptionContext.CatchBlock.IsTopLevel);
        }