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
{
"context": "Tests whether the agent uses the ASP.NET Core 8 IExceptionHandler interface for global exception handling, registers it correctly via AddExceptionHandler and AddProblemDetails, produces RFC 7807 ProblemDetails responses with all required fields, sets the correct Content-Type, and avoids leaking internal details.",
"type": "weighted_checklist",
"checklist": [
{
"name": "IExceptionHandler interface",
"description": "GlobalExceptionHandler implements the IExceptionHandler interface (not a custom middleware class with InvokeAsync/RequestDelegate)",
"max_score": 12
},
{
"name": "AddExceptionHandler registration",
"description": "Program.cs calls builder.Services.AddExceptionHandler<GlobalExceptionHandler>() (or equivalent generic overload)",
"max_score": 10
},
{
"name": "AddProblemDetails registration",
"description": "Program.cs calls builder.Services.AddProblemDetails()",
"max_score": 8
},
{
"name": "UseExceptionHandler called",
"description": "Program.cs calls app.UseExceptionHandler() (with no path argument, or equivalent) to activate the handler",
"max_score": 8
},
{
"name": "TryHandleAsync returns true",
"description": "The TryHandleAsync method returns true after handling any exception, signalling that the exception was handled",
"max_score": 8
},
{
"name": "ProblemDetails title field",
"description": "Error responses include a 'Title' (or 'title') field set to a string error code (e.g. 'RESOURCE_NOT_FOUND', 'CONFLICT', 'INTERNAL_SERVER_ERROR')",
"max_score": 8
},
{
"name": "ProblemDetails detail field",
"description": "Error responses include a 'Detail' (or 'detail') field with a human-readable explanation of the specific error",
"max_score": 8
},
{
"name": "ProblemDetails instance field",
"description": "Error responses include an 'Instance' (or 'instance') field set to the HTTP request path (httpContext.Request.Path)",
"max_score": 10
},
{
"name": "Content-Type application/problem+json",
"description": "The response Content-Type is explicitly set to 'application/problem+json' (not 'application/json')",
"max_score": 10
},
{
"name": "No stack trace in 500 response",
"description": "The generic (non-ApiException) catch branch returns a fixed generic message (e.g. 'An unexpected error occurred') rather than ex.Message, ex.StackTrace, or ex.ToString()",
"max_score": 10
},
{
"name": "Typed exception status codes",
"description": "Custom exception types carry their own HTTP status code and the handler uses that code (not a hardcoded value) when building the ProblemDetails response",
"max_score": 8
}
]
}evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
aspnet-error-handling
verifiers