Skip to content

Global Exception Handling sample: new net10.0 folder for the ported students example - #2245

Merged
vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/3666-global-error-handling-aspnetcore
Sep 29, 2026
Merged

vladimir-pecanac-main merged 2 commits into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/3666-global-error-handling-aspnetcore

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Adds exception-handling/GlobalExceptionHandlingInAspNetCore for the updated article "Global Exception Handling in ASP.NET Core Web API" (https://code-maze.com/global-error-handling-aspnetcore/). The old global-error-handling-aspnetcore repo only held a net5.0 start project, so this is a new folder with the article's end state.

  • net10.0 Web API from dotnet new webapi --use-controllers --no-openapi, the weather files removed
  • Models/Student.cs, Models/DataManager.cs and ValuesController with the article's forced AccessViolationException
  • CustomExceptionMiddleware/ExceptionMiddleware.cs writing through IProblemDetailsService, with its ConfigureCustomExceptionMiddleware() extension (kept for comparison, not registered)
  • ExceptionHandlers/AccessViolationExceptionHandler.cs (IExceptionHandler), registered with AddProblemDetails() and UseExceptionHandler() in Program.cs
  • Tests: 3 integration tests (Microsoft.AspNetCore.Mvc.Testing 10.0.12, xunit.v3.mtp-off 4.0.1), none named Live

Local run: dotnet build -c Release, 0 errors, 1 warning (CS0162, the article's deliberate forced exception); dotnet test, 3 of 3 passed.

Ports the article's students example to .NET 10: try-catch controller, built-in UseExceptionHandler with AddProblemDetails, custom exception middleware writing through IProblemDetailsService, and an IExceptionHandler for AccessViolationException. Three integration tests.
@vladimir-pecanac-main
vladimir-pecanac-main merged commit ff70523 into CodeMazeBlog:main Sep 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant