public ErrorHandlingPipelines(IResponseNegotiator responseNegotiator, INancyErrorMap errorMap)
        {
            this.responseNegotiator = responseNegotiator;
            this.errorMap = errorMap;

            AfterRequest = new AfterPipeline();
            BeforeRequest = new BeforePipeline();
            OnError = new ErrorPipeline();

            OnError += (ctx, ex) =>
            {
                var nonAggregateException = ex.TrimAggregateException();

                if (!errorMap.Contains(nonAggregateException.GetType()))
                {
                    Logger.DebugFormat("Exception type not found in ErrorMap. Exception: {0}", nonAggregateException.GetType());

                    ctx.Response = DefaultError(ctx);
                }
                else
                {
                    ctx.Response = Error(nonAggregateException, ctx);
                }

                return null;
            };
        }
        public CoercingPipelines()
        {
            AfterRequest = new AfterPipeline();
            BeforeRequest = new BeforePipeline();
            OnError = new ErrorPipeline();

            OnError += (ctx, ex) => ctx.Response;
        }
示例#3
0
 private Task InvokePostRequestHook(NancyContext context, CancellationToken cancellationToken, AfterPipeline pipeline)
 {
     return pipeline == null ? TaskHelpers.CompletedTask : pipeline.Invoke(context, cancellationToken);
 }
示例#4
0
 private Task InvokePostRequestHook(NancyContext context, CancellationToken cancellationToken, AfterPipeline pipeline)
 {
     return(pipeline.Invoke(context, cancellationToken));
 }
示例#5
0
 private Task InvokePostRequestHook(NancyContext context, CancellationToken cancellationToken, AfterPipeline pipeline)
 {
     return(pipeline == null ? TaskHelpers.CompletedTask : pipeline.Invoke(context, cancellationToken));
 }
示例#6
0
 private Task InvokePostRequestHook(NancyContext context, CancellationToken cancellationToken, AfterPipeline pipeline)
 {
     return pipeline.Invoke(context, cancellationToken);
 }