Search code examples
nancy

Handle Nancy error in OnError or OnError.AddItemToEndOfPipeline?


The Nancy documentation says that you can use pipelines.OnError += (x, y) =>... to handle errors, but I have seen some tutorials using pipelines.OnError.AddItemToEndOfPipeline((x, y) =>....

Both seem to result in the error being handled correctly. Is there an actual difference between the two?


Solution

  • No pipelines.OnError += (x ,y) => ... adds the handler to the end of the pipeline, just like pipelines.OnError.AddItemToEndOfPipeline((x, y) => ..) does.

    See the source code: https://github.com/NancyFx/Nancy/blob/master/src/Nancy/ErrorPipeline.cs#L39