Skip to content

Commit

Permalink
♻️ 403 simplify global exception handling (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmackay authored Oct 29, 2024
1 parent af27df3 commit df198fb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public async Task<ErrorOr<Success>> Handle(ExecuteMissionCommand request, Cancel
if (team is null)
return TeamErrors.NotFound;

team.ExecuteMission(request.Description);
var result = team.ExecuteMission(request.Description);
if (result.IsError)
return result;

await dbContext.SaveChangesAsync(cancellationToken);

return new Success();
Expand Down
17 changes: 0 additions & 17 deletions src/WebApi/Filters/DefaultExceptionHandlerExtensions.cs

This file was deleted.

8 changes: 3 additions & 5 deletions src/WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
using SSW.CleanArchitecture.WebApi;
using SSW.CleanArchitecture.WebApi.Extensions;
using SSW.CleanArchitecture.WebApi.Features;
using SSW.CleanArchitecture.WebApi.Filters;
using SSW.CleanArchitecture.WebApi.HealthChecks;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.Services.AddProblemDetails();

builder.Services.AddWebApi(builder.Configuration);
builder.Services.AddApplication();
Expand All @@ -31,16 +31,14 @@
app.MapOpenApi();
app.MapScalarApiReference(options => options.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient));
app.UseHealthChecks();

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseDefaultExceptionHandler();
app.MapHeroEndpoints();
app.MapTeamEndpoints();
app.UseEventualConsistencyMiddleware();

app.MapDefaultEndpoints();

app.UseEventualConsistencyMiddleware();
app.UseExceptionHandler();

app.Run();

0 comments on commit df198fb

Please sign in to comment.