From 7e294935ab2e04bff7f57bbee894decb986d0971 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 20 Dec 2021 10:41:07 -0600 Subject: add UseExceptionHandler --- src/slskd/Startup.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index ac4a2789..765afa18 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -25,6 +25,8 @@ namespace slskd using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; + using Microsoft.AspNetCore.Diagnostics; + using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; @@ -271,6 +273,11 @@ namespace slskd // DbContext explicitly. InitializeDbContexts(app); + app.UseExceptionHandler(a => a.Run(async context => + { + await context.Response.WriteAsJsonAsync(context.Features.Get().Error.Message); + })); + app.UseCors("AllowAll"); if (OptionsAtStartup.Web.Https.Force) -- cgit v1.2.3