refactor: add Result<T> pattern and global exception handler for consistent error handling

This commit is contained in:
V1ck3s
2026-01-08 19:31:05 +01:00
parent cb37c7f69a
commit 43c9a2e808
4 changed files with 334 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ using octo_fiesta.Services.Deezer;
using octo_fiesta.Services.Qobuz;
using octo_fiesta.Services.Local;
using octo_fiesta.Services.Validation;
using octo_fiesta.Middleware;
var builder = WebApplication.CreateBuilder(args);
@@ -14,6 +15,10 @@ builder.Services.AddHttpClient();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Exception handling
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
builder.Services.AddProblemDetails();
// Configuration
builder.Services.Configure<SubsonicSettings>(
builder.Configuration.GetSection("Subsonic"));
@@ -66,6 +71,8 @@ builder.Services.AddCors(options =>
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseExceptionHandler(_ => { }); // Global exception handler
if (app.Environment.IsDevelopment())
{
app.UseSwagger();