HAKOM.ErrorHandling.Http.Net Assembly
The <strong>HAKOM.ErrorHandling.Http.Net</strong> assembly provides HTTP-specific error handling for ASP.NET Core web applications following the RFC 7807 problem-details standard.
Remarks
Section titled “Remarks”This assembly bridges the HAKOM error-handling core (HakomException)
with ASP.NET Core, ensuring that all errors — whether thrown as exceptions, returned as
Failure results, or produced by model-binding validation —
are serialized as RFC 7807 compliant application/problem+json responses.
The assembly also provides OpenAPI/Swagger integration through operation and schema filters that automatically document error responses and Result<TValue> return types in generated API specifications.
Registering error handling in a web application:var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();builder.Services.AddHakomServices(container =>{ container .UseSerializerFactory() .UseSerializationContractTypeProvider() .UseJsonSerialization() .UseDefaultJsonSerializer() .UseResultJsonSerialization();});
builder.AddHakomErrorHandling();
builder.Services.AddControllers(options =>{ options.AddProblemDetailsFormatter(); options.AddSuccessResultFormatter();});public class ItemsController : ControllerBase{ private readonly IHttpFailureFactory _failureFactory;
public async Task<Result<Item>> Get(string name, CancellationToken ct) { return _failureFactory.CreateNotFound<Item>("Item", "name", name); }}var options = new JsonSerializerOptions{ PropertyNameCaseInsensitive = true};options.AddErrorSerialization();| Namespaces | |
|---|---|
| HAKOM.ErrorHandling.Http.Net.Api | Contains the public API surface for HTTP error handling in HAKOM web applications. |
| HAKOM.ErrorHandling.Http.Net.Api.Exceptions | Contains exception types specific to HTTP error handling in HAKOM web applications. |
| HAKOM.ErrorHandling.Http.Net.Api.Exceptions.HttpRequestFailedExceptions | Contains exception types that represent specific categories of HTTP request failures. |
| HAKOM.ErrorHandling.Http.Net.Api.Exceptions.HttpRequestFailedExceptions.ClientErrorExceptions | Contains concrete exception types for specific HTTP 4xx client errors. |
| HAKOM.ErrorHandling.Http.Net.Api.Extensions | Contains extension methods for integrating HAKOM error handling into ASP.NET Core applications. |
| HAKOM.ErrorHandling.Http.Net.Api.Serialization.Json.Extensions | Contains extension methods for configuring JSON serialization of HAKOM error types without requiring the full HAKOM dependency injection container. |
Was this page helpful?Thanks for your feedback!