mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
refactor: add Result<T> pattern and global exception handler for consistent error handling
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user