Improve exception handling with ProblemDetails responses
ExceptionHandlingMiddleware now returns structured ProblemDetails responses for errors, including specific handling for InvalidOperationException (400 Bad Request) and general exceptions (500 Internal Server Error). Responses use "application/problem+json" content type and include trace IDs. ProblemDetails support is also registered in Program.cs.
This commit is contained in:
@@ -13,6 +13,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddProblemDetails();
|
||||
|
||||
// TODO: allow listed origins configured in appsettings.json
|
||||
// In any case, dont let them to free to use without cors. if there is no origin specified, block all.
|
||||
|
||||
Reference in New Issue
Block a user