Error handling for ASP.NET Core APIs — exception middleware, ProblemDetails,
94
90%
Does it follow best practices?
Impact
100%
1.13xAverage score across 5 eval scenarios
Passed
No known issues
The engineering team at a travel booking startup is building a new .NET 8 REST API for their flight search and reservation service. The API will be consumed by a mobile app and third-party travel agents, both of whom need machine-readable error responses they can reliably parse and display to end users.
Currently the prototype has no centralized error handling: if something goes wrong, clients receive raw ASP.NET Core 500 responses or HTML error pages. The product team has been told by a major travel agency partner that they require error responses to conform to RFC 7807 (the HTTP Problem Details standard), as their client SDK knows how to parse that format automatically.
Your job is to build out the error handling layer for this API. There are three domain-specific error conditions that need typed representations: a resource not found (e.g. flight or booking not found), a business rule violation (e.g. trying to cancel a flight that already departed), and a conflict (e.g. seat already booked by another user). All of these should flow through a single, centralized handler rather than being scattered across individual controllers.
Produce the following files in your working directory:
GlobalExceptionHandler.cs — the centralized exception handler classExceptions.cs — the custom exception type definitionsProgram.cs — the application startup/pipeline configuration registering the handler and mapping a single sample controller routeerror_handling_notes.md — a brief explanation (2–4 sentences) of how the error handling is wired up and how a client can identify error types from the responseThe files should form a coherent, self-consistent implementation. The GlobalExceptionHandler.cs and Program.cs should reflect how the handler is registered and invoked in .NET 8.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
aspnet-error-handling
verifiers