aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-12-20 10:41:07 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-12-20 10:41:07 -0600
commit7e294935ab2e04bff7f57bbee894decb986d0971 (patch)
tree3eeb901a06e514104c5becc67c99d24ecb53ab47 /src
parent2b307601cd37a58e79090517bdb385bce98ff3ef (diff)
downloadslskd-7e294935ab2e04bff7f57bbee894decb986d0971.tar.gz
add UseExceptionHandler
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Startup.cs7
1 files changed, 7 insertions, 0 deletions
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<IExceptionHandlerPathFeature>().Error.Message);
+ }));
+
app.UseCors("AllowAll");
if (OptionsAtStartup.Web.Https.Force)