diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-20 10:41:07 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-20 10:41:07 -0600 |
| commit | 7e294935ab2e04bff7f57bbee894decb986d0971 (patch) | |
| tree | 3eeb901a06e514104c5becc67c99d24ecb53ab47 /src | |
| parent | 2b307601cd37a58e79090517bdb385bce98ff3ef (diff) | |
| download | slskd-7e294935ab2e04bff7f57bbee894decb986d0971.tar.gz | |
add UseExceptionHandler
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Startup.cs | 7 |
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) |
