WebApplicationBuilderExtensions Class
HAKOM.ErrorHandling.Http.Net.Api.Extensions
Section titled “HAKOM.ErrorHandling.Http.Net.Api.Extensions”Adds services for error handling to a web application.
public static class WebApplicationBuilderExtensionsInheritance System.Object 🡒 WebApplicationBuilderExtensions
Methods
Section titled “Methods”WebApplicationBuilderExtensions.AddHakomErrorHandling(this WebApplicationBuilder) Method
Section titled “WebApplicationBuilderExtensions.AddHakomErrorHandling(this WebApplicationBuilder) Method”Adds output of Microsoft.AspNetCore.Mvc.ProblemDetails to the application.
This must be added after calling .AddMvc/.AddControllers, because the MVC framework adds additional services which have to be removed for consistent serialization of problem details across the application.
For this to work properly, it requires that serialization is set up, so make sure to add the respective services. Example:
builder.Services.AddHakomServices(container=>{ container .UseSerializerFactory() .UseSerializationContractTypeProvider() .UseJsonSerialization() .UseDefaultJsonSerializer() .UseResultJsonSerialization();});public static Microsoft.AspNetCore.Builder.WebApplicationBuilder AddHakomErrorHandling(this Microsoft.AspNetCore.Builder.WebApplicationBuilder builder);Parameters
Section titled “Parameters”builder Microsoft.AspNetCore.Builder.WebApplicationBuilder
The Microsoft.AspNetCore.Builder.WebApplicationBuilder to add error handling capabilities to.
Returns
Section titled “Returns”Microsoft.AspNetCore.Builder.WebApplicationBuilder
The builder for chaining additional calls to it.