/// <summary> /// Adds middleware to the pipeline that will catch exceptions, log them, and set the status code on the response. /// The status code of the response will not be altered is the response has already started. /// </summary> /// <param name="app"></param> /// <param name="transformations"></param> /// <returns></returns> public static IApplicationBuilder UseExceptionTransformations(this IApplicationBuilder app, ITransformationCollection transformations) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (transformations == null) { throw new ArgumentNullException(nameof(transformations)); } var options = new ExceptionTransformationOptions(transformations); return app.UseMiddleware<ExceptionTransformationMiddleware>(options); }
internal ExceptionTransformationOptions(ITransformationCollection transformations) { this.Transformations = transformations; }