public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerManager logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } //Exception Handling ExceptionMiddlewareExtensions.ConfigureExceptionHandler(app, logger); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Cars"); }); app.UseHttpsRedirection(); app.UseMvc(routes => routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}")); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Bookstore API"); }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } ExceptionMiddlewareExtensions.ConfigureExceptionHandler(app); app.UseHttpsRedirection(); app.UseRouting(); app.UseStaticFiles(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public void ConfigureExceptionHandler_Executed_ThrowsNoException() { var mockApplicationBuilder = Substitute.For <IApplicationBuilder>(); try { ExceptionMiddlewareExtensions.ConfigureExceptionHandler(mockApplicationBuilder); } catch (Exception ex) { Assert.True(false, $"Executing ConfigureExceptionHandler method should not return an exception. Exception Type {ex.GetType().ToString()} with message '{ex.Message}' caught."); } }