Add phase-aware frontend shell, polling client, and global exception handler

This commit is contained in:
2026-01-28 15:05:54 +01:00
parent 44514f8ecc
commit 74dcad74aa
5 changed files with 455 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
using GameList.Data;
using GameList.Domain;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.Sqlite;
@@ -46,6 +47,23 @@ builder.Services.ConfigureHttpJsonOptions(options =>
var app = builder.Build();
app.UseExceptionHandler(handler =>
{
handler.Run(async context =>
{
var feature = context.Features.Get<IExceptionHandlerFeature>();
var logger = context.RequestServices.GetRequiredService<ILoggerFactory>().CreateLogger("GlobalException");
if (feature?.Error != null)
{
logger.LogError(feature.Error, "Unhandled exception");
}
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
context.Response.ContentType = "application/json";
await context.Response.WriteAsJsonAsync(new { error = "Unexpected server error" });
});
});
// Ensure database and migrations are applied on startup
using (var scope = app.Services.CreateScope())
{