CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/aspnet-error-handling

Error handling for ASP.NET Core APIs — exception middleware, ProblemDetails,

94

1.13x
Quality

90%

Does it follow best practices?

Impact

100%

1.13x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-3/

Logistics API Gateway — Consistent Errors for All HTTP Status Codes

Problem Description

A logistics company operates an internal ASP.NET Core API gateway used by warehouse management software and mobile delivery apps. The API already has a global exception handler that returns structured JSON error responses whenever an exception is thrown inside a controller.

However, the mobile team has reported two classes of problems that the exception handler does not cover:

  1. Typos in client URLs — when an app version contains a hardcoded URL like /api/v1/shipmments/123 (double 'm'), the server returns a raw HTML 404 page from ASP.NET Core's routing layer rather than a structured JSON response. The mobile app cannot parse this and shows a blank screen.
  2. Wrong HTTP method — when an older client calls GET /api/shipments instead of POST /api/shipments/search, it gets a 405 Method Not Allowed response in plain text, again unparseable.

The backend team has been asked to ensure that all non-200 HTTP responses — including routing misses and method mismatches that never reach a controller — return a consistent, machine-readable format with the appropriate Content-Type.

Output Specification

Produce the following files in your working directory:

  • Program.cs — the complete middleware pipeline configuration that addresses both problem classes, alongside a sample controller registration
  • pipeline_notes.md — a short explanation (3–5 sentences) of what middleware was added, what categories of errors it handles that the exception handler alone does not, and where in the pipeline it is placed

The Program.cs should demonstrate the correct ordering of all relevant middleware components. You do not need to implement controller logic — a stub MapControllers() call is sufficient.

evals

tile.json