Beispiel #1
0
        public async Task Invoke(ICommunicationContext env)
        {
            var shouldRetry = await ShouldRetryRendering(env);

            if (!shouldRetry)
            {
                return;
            }

            EnsureCanRetry(env);

            env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue;
            env.PipelineData.ResponseCodec = null;


            try
            {
                await _responsePipeline.Invoke(env);
            }
            catch (Exception e)
            {
                ThrowWithNewError(env, "Error re-rendering the response",
                                  "An error occured while trying to re-render the response.", e);
            }

            if (env.PipelineData.PipelineStage.CurrentState == PipelineContinuation.RenderNow)
            {
                ThrowWithNewError(env,
                                  "Re-rendering failed",
                                  "A component set the response pipeline in render now mode one too many times.");
            }
        }
Beispiel #2
0
        async Task InvokeWithErrorConneg(ICommunicationContext env)
        {
            var exceptionHappened = false;

            try
            {
                await _responsePipeline.Invoke(env);
            }
            catch (Exception e)
            {
                env.ServerErrors.Add(new Error {
                    Exception = e
                });
                exceptionHappened = true;
            }
            log.WriteInfo($"Exception: {exceptionHappened}, Errors: {env.ServerErrors.Count()}, State: {env.PipelineData.PipelineStage.CurrentState}");
            if (exceptionHappened)
            {
                env.SetOperationResultToServerErrors();
            }
            if (exceptionHappened ||
                env.PipelineData.PipelineStage.CurrentState == PipelineContinuation.RenderNow)
            {
                env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Continue;
                env.PipelineData.ResponseCodec = null;

                try
                {
                    log.WriteInfo($"Trying to re-render");

                    await _responsePipeline.Invoke(env);

                    log.WriteInfo($"Errors: {env.ServerErrors.Count()}, State: {env.PipelineData.PipelineStage.CurrentState}");

                    if (env.PipelineData.PipelineStage.CurrentState == PipelineContinuation.RenderNow)
                    {
                        throw new PipelineAbortedException(env.ServerErrors);
                    }
                }
                catch (Exception e)
                {
                    env.ServerErrors.Add(new Error {
                        Exception = e
                    });

#pragma warning disable 618
                    // set for compatibility
                    env.PipelineData.PipelineStage.CurrentState = PipelineContinuation.Abort;
#pragma warning restore 618

                    throw new PipelineAbortedException(env.ServerErrors);
                }
            }
        }
 public Task RunAsync(ICommunicationContext env)
 {
     if (env.PipelineData.PipelineStage == null)
     {
         env.PipelineData.PipelineStage = new PipelineStage();
     }
     return(_middleware.Invoke(env));
 }
Beispiel #4
0
        public async Task Invoke(ICommunicationContext env)
        {
            await InvokeSafe(_requestPipeline, env);
            await InvokeSafe(_responsePipeline, env);

            if (env.PipelineData.PipelineStage.CurrentState == PipelineContinuation.Abort)
            {
                await _catastrophicFail.Invoke(env);
            }
            await _cleanup.Invoke(env);
        }
 async Task InvokeSafe(IPipelineMiddleware middleware, ICommunicationContext env)
 {
   try
   {
     await middleware.Invoke(env);
   }
   catch (Exception e)
   {
     env.ServerErrors.Add(new Error {Exception = e});
     env.Abort();
   }
 }
Beispiel #6
0
 async Task InvokeSafe(IPipelineMiddleware middleware, ICommunicationContext env)
 {
     try
     {
         await middleware.Invoke(env);
     }
     catch (Exception e)
     {
         env.ServerErrors.Add(new Error {
             Exception = e
         });
         env.Abort();
     }
 }
        public async Task Invoke(ICommunicationContext env)
        {
            await _inner.Invoke(env);

            var suspend = env.PipelineData.Suspend;
            var resume  = env.PipelineData.Resume;

            if (suspend != null && resume != null)
            {
                suspend.SetResult(null);
                await resume.Task;
            }
            await Next.Invoke(env);
        }
Beispiel #8
0
 public async Task Invoke(ICommunicationContext env)
 {
     using (Log.Operation(this, _log))
     {
         try
         {
             await _next.Invoke(env);
         }
         catch (Exception e)
         {
             Log.WriteError($"Exception has happened: {Environment.NewLine}{e}");
             throw;
         }
     }
 }
Beispiel #9
0
 public async Task Invoke(ICommunicationContext env)
 {
     using (Log.Operation(this, _log))
     {
         try
         {
             await _next.Invoke(env);
         }
         catch (Exception e)
         {
             Log.WriteError($"Exception has happened: {Environment.NewLine}{e}");
             throw;
         }
         finally
         {
             foreach (var error in env.ServerErrors)
             {
                 Log.WriteError(error.ToString());
             }
         }
     }
 }
Beispiel #10
0
 public Task Invoke(ICommunicationContext env)
 {
     return(_next.Invoke(env));
 }