/// <summary> /// Adds a filter to the end of the exception management filter pipeline. /// </summary> /// <param name="builder"></param> /// <param name="filter">An exception filter.</param> /// <returns></returns> public static ExceptionHandlerBuilder AddFilter(this ExceptionHandlerBuilder builder, ExceptionFilterDelegate filter) { builder.Services.Configure <ExceptionManagementOptions>(options => { options.Filters.Add(filter); }); return(builder); }
/// <summary> /// Configures the use of the <see cref="Handlers.WebApiExceptionHandler(ExceptionContext)">WebApiExceptionHandler</see> handler, and a generic error response for unsafe exceptions. /// </summary> /// <param name="builder"></param> /// <returns></returns> public static ExceptionHandlerBuilder AddWebApiDefaults(this ExceptionHandlerBuilder builder) { builder.Services.Configure <ExceptionManagementOptions>(options => { options.Handler = options.Handler ?? Handlers.WebApiExceptionHandler; options.UnsafeResult = options.UnsafeResult ?? ExceptionManagementOptions.GenericErrorResult; }); return(builder); }